How to write SAS program for residual transformation on self-paced reading data

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 6
Accepted Solution

How to write SAS program for residual transformation on self-paced reading data

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

?




Accepted Solutions
Solution
‎03-22-2018 02:41 PM
Super User
Posts: 23,776

Re: How to write SAS program for residual transformation on self-paced reading data


proc
reg data=sashelp.class;
by sex; model weight = height age; output out=want pred = p residual=r; quit; proc print data=want;run;

View solution in original post


All Replies
Super User
Posts: 23,776

Re: How to write SAS program for residual transformation on self-paced reading data

Posted in reply to PeteCthulu
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. 

Occasional Contributor
Posts: 6

Re: How to write SAS program for residual transformation on self-paced reading data

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....

Respected Advisor
Posts: 3,066

Re: How to write SAS program for residual transformation on self-paced reading data

Posted in reply to PeteCthulu

You need to add

 

by participant;

into the PROC REG commands.

--
Paige Miller
Solution
‎03-22-2018 02:41 PM
Super User
Posts: 23,776

Re: How to write SAS program for residual transformation on self-paced reading data


proc
reg data=sashelp.class;
by sex; model weight = height age; output out=want pred = p residual=r; quit; proc print data=want;run;
Esteemed Advisor
Posts: 5,543

Re: How to write SAS program for residual transformation on self-paced reading data

Posted in reply to PeteCthulu

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.

 

PG
Occasional Contributor
Posts: 6

Re: How to write SAS program for residual transformation on self-paced reading data

Thanks! I'll try this too!

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 6 replies
  • 118 views
  • 3 likes
  • 4 in conversation