BookmarkSubscribeRSS Feed
JianJian
Calcite | Level 5

Hello, I am using RRR for an analysis of Dietary pattern. I have data for two sets of data for 2021 and 2022, where data for the response variable is missing in 2021, so I want to calculate the 2021 meal score using the dietary pattern coefficients generated by the 2022 RRR. So far I have extracted Xloading, how to calculate the final meal score for each sample. Thanks!

14 REPLIES 14
PaigeMiller
Diamond | Level 26

Include the 2021 data with the missing response in your data set that also has the 2022 data, and then run RRR and ask for the output to include scores and predicted values.

 

More details here: https://blogs.sas.com/content/iml/2014/02/17/the-missing-value-trick-for-scoring-a-regression-model....

--
Paige Miller
JianJian
Calcite | Level 5

I'm very sorry, because I am a new user to SAS, I am not familiar with it, the following is my code for RRR, how to do predict  I still can't, can you please tell me how to write the later predict code. Thank you!

proc pls data=data2 method=rrr varss nfac=2 details censcale;
model e49 e11=
f1 f2 f3 f4 f5 f6 f7 f8 f9 f11 f12 f13 f14 f15 f16 f17 f18 f19 f20 f21 f22 f23 f24 f25 f26 f27/solution;
output out=data3 XSCORE=xscore YSCORE=yscore;
run;

PaigeMiller
Diamond | Level 26

The SAS data set used in your code which you named data2 should contain both the 2021 and 2022 data. You need to modify the OUTPUT statement in PROC PLS to include the PREDICTED option.

 

output out=data3 XSCORE=xscore YSCORE=yscore predicted=pred_e49 pred_e11;

 

 

--
Paige Miller
JianJian
Calcite | Level 5

I'm really sorry, factor score of dietary pattern = factor loadings * standard food intakes, why should I predict the dependent variable?

PaigeMiller
Diamond | Level 26

@JianJian wrote:

I'm really sorry, factor score of dietary pattern = factor loadings * standard food intakes, why should I predict the dependent variable?


I don't understand the question.

--
Paige Miller
JianJian
Calcite | Level 5
I'm very sorry, I didn't make my question clear, my dependent variable is now only available in 2022, but I have a diet for two years, should I first run with the data of 2022, then predict the standard dietary intake in 2021, and finally calculate the factor score, at present I will only do the RRR in 2022, but will not derive the factor score of the entire population
PaigeMiller
Diamond | Level 26

I have already explained this. The data used in PROC PLS should contain BOTH 2021 and 2022. The scores and predicted values will be computed for all of the data, 2021 and 2022, and the model fit will be based on just 2022 data (since the 2021 data has no Y values).

--
Paige Miller
PaigeMiller
Diamond | Level 26

ADDING: Since you have 27 x-variables and 2 y-variables, I would think PLS would be a better choice than RRR for this data. It will handle the multicollinearity of the X variables better than RRR will.

--
Paige Miller
JianJian
Calcite | Level 5

谢谢你之前的回答。现在,我又有一个问题,为什么基于 xweights 和标准化食物摄入量的产品总和不等于直接从 proc pls 获得的因子分数(输出 xscore=)?

PaigeMiller
Diamond | Level 26

Translation: "Thanks for your previous answer. Now, I have another question, why the sum of products based on xweights and normalized food intake is not equal to the factor score obtained directly from proc pls (output xscore=)?"

 

Show the code you used. Show output that illustrates the problem.

--
Paige Miller
JianJian
Calcite | Level 5

Data2 包含 2021 年和 2022 年。我使用的代码如下,proc pls data=data2 method=rrr varss nfac=2 details censcale;型号 E49 E11= F1 F2 F3 F4 F5 F6 F7 F8 F9 F11 F12 F13 F14 F15 F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27/解决方案;输出输出=数据3 XSCORE=xscore YSCORE=yscore predicted=pred_e49 pred_e11;跑;

PaigeMiller
Diamond | Level 26

I said: "Show the code you used. Show output that illustrates the problem."

 

I don't see any output that illustrates the problem. You need to provide enough detail so I can look at it and see the problem.

--
Paige Miller
JianJian
Calcite | Level 5

proc pls data=data2 method=rrr varss nfac=2 details censcale;
型号 E49 E11=
F1 F2 F3 F4 F5 F6 F7 F8 F9 F11 F12 F13 F14 F15 F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27/解决方案;
输出输出=数据3 XSCORE=xscore YSCORE=yscore predicted=pred_e49 pred_e11;;
跑;

我比较了 stata 计算的饮食评分和 SAS 计算的 xscore 没有一致性,但文献说 SAS 和 stata 的评分应该是一致的

PaigeMiller
Diamond | Level 26

What "literature" says the scores from SAS and STATA should be the same? In multivariate procedures such as this, different algorithms can produce different results, which can be entirely different (which may or may not be a problem), or the scores can have the opposite sign (which is not a problem), or they can produce the same results but scaled differently (which is not a problem either).

 

I will not download attachments. If you are going to show us SAS output, you need to include it in your reply by either copying and pasting as text, or as a screen capture using the "Insert Photos" icon.

--
Paige Miller

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 14 replies
  • 2249 views
  • 2 likes
  • 2 in conversation