03-20-2018 02:33 PM
I'm using SAS 9.4.
I have data for about 50 participants, who each read a series of sentences that have the same structure. The reading time (in milliseconds) for each word in each sentence was recorded. I want to get a regression line for how the word length (in characters) relates to reading time for each participant, and I want to then convert the reading time measurement into the corresponding residual from these regression equations for each data point. I've tried to do this with some stupid things, like below. I don't quite get it. I give an example of how the data look for these variables further below. Please help!
PROC GLM;
model Readingtime= Wordlength;
Do by Participant#;
Participant# | Readingtime | Wordlength | Residual |
300 | 1042
| 6 | ? |
300 | 742
| 4 | ? |
300 | 615 | 4 | ? |
300 | 668 | 5 | ? |
300 | 562 | 3 | ? |
301 | 677 | 6 | ? |
301 | 694 | 4 | ? |
301 | 730 | 4 | ? |
301 | 512 | 5 | ? |
301 | 476 | 3 | ? |
302 | 1001 | 6 | ? |
302 | 890 | 4 | ? |
302 | 640 | 4 | ? |
302 | 708 | 5 | ? |
302 | 544 | 3 | ? |
03-20-2018 04:09 PM
proc reg data=sashelp.class;
by sex;
model weight = height age;
output out=want pred = p residual=r;
quit;
proc print data=want;run;
03-20-2018 02:56 PM
proc reg data=sashelp.class;
model weight = height age;
output out=want pred = p residual=r;
quit;
proc print data=want;run;
You need to create an OUTPUT data set, see the code above for a fully worked example.
In general, you should always have a DATA statement so that you know which data set your procedure is using.
03-20-2018 03:55 PM
I don't understand how this would get the Yhat for the regression equation for each participant and then get the residual for each data point....
03-20-2018 04:02 PM
You need to add
by participant;
into the PROC REG commands.
03-20-2018 04:09 PM
proc reg data=sashelp.class;
by sex;
model weight = height age;
output out=want pred = p residual=r;
quit;
proc print data=want;run;
03-20-2018 05:12 PM
A power model would fit pretty well I bet
data temp;
set have;
lReadingTime = log(readingtime);
lWordLength = log(WordLength);
run;
proc mixed data=temp;
class participant;
model lreadingtime = lwordlength / s outpred=outpred residual;
random participant / solution;
ods output SolutionR=SolutionR;
run;
make sure you include all the same words for every reader.
03-22-2018 02:42 PM
Thanks! I'll try this too!
Need further help from the community? Please ask a new question.