BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
RobinN
Fluorite | Level 6

Hello,

 

I'm currently working on a SAS Programm to fit my data of a germinating fungus to a given logistic function. This works fine for now, as the estimated values fit well to the data and predicted values based on that function seem acceptable. But when I try to plot this data the resulting graph looks like this:  

 

RobinN_0-1603991172959.png

 

Does anyone has any suggestions regarding this problem? I'm using SAS University Edition / SAS Studio 3.8

Thanks for your help!

 

The code used to create this graph is as follows: 

data fungi;
     input time germrate;
     datalines;
9       0
9       0
9       0
9       0
9       0
9       0
9       0
9       0
12      1
12      1
12      1
9       1
12      2
12      3
12      4
12      4
12      5
12      5
15      11
15      18
15      20
15      21
9       22
15      24
15      27
15      27
9       28
9       28
9       29
9       31
9       33
15      34
15      37
18      43
18      45
18      52
18      52
18      54
15      55
18      58
18      58
18      63
18      71
21      72
12      73
21      74
12      74
12      76
12      76
12      77
21      78
15      79
12      80
21      81
15      82
21      83
21      84
21      84
24      85
15      85
24      86
21      86
24      87
21      87
21      87
24      88
24      90
24      90
24      90
21      90
18      90
18      91
15      91
24      92
24      92
21      92
21      92
21      92
18      92
24      93
24      93
18      93
15      93
24      94
24      94
24      95
24      96
18      96
21      97
18      98
96      99
96      100
96      99
96      98
96      97
96      100

   ;


proc nlin  data=fungi;
 	parms   Pmax=98 teta=15 ;d=6 ;

 	model germrate = Pmax*(1-(1/(1+((time/teta)**d))));
run;

proc nlin data=fungi method=newton;   
	parameters  Pmax=98 teta=15 ;d=6 ;  
	model germrate = Pmax*(1-(1/(1+((time/teta)**d)))); 
	output out=nlinout predicted=pred l95m=l95mean u95m=u95mean l95=l95ind u95=u95ind; 
run; 
proc print data=nlinout; 
run;

data filler;   
do time = 0 to 96 by 2;     
predict=1;     
output;   
end; 
run;

data fitthis; 
set fungi filler; 
run;

proc nlin data=fitthis method=newton;   
	parameters  Pmax=98 teta=15 ;d=6 ;  
	model germrate = Pmax*(1-(1/(1+((time/teta)**d))));   
	output out=nlinout predicted=pred l95m=l95mean u95m=u95mean; 
run; 

proc print data=nlinout(where=(predict=1)); run;

proc sgplot data=nlinout;

   scatter x=time y=germrate;
   series x=time y=pred;
   band upper=u95mean lower=l95mean x=time ;
   
   run;

 

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
djrisks
Barite | Level 11

Hi @RobinN , you just need to sort your graph by time before you do the plot. Please see the example below.

 

data fungi;
     input time germrate;
     datalines;
9       0
9       0
9       0
9       0
9       0
9       0
9       0
9       0
12      1
12      1
12      1
9       1
12      2
12      3
12      4
12      4
12      5
12      5
15      11
15      18
15      20
15      21
9       22
15      24
15      27
15      27
9       28
9       28
9       29
9       31
9       33
15      34
15      37
18      43
18      45
18      52
18      52
18      54
15      55
18      58
18      58
18      63
18      71
21      72
12      73
21      74
12      74
12      76
12      76
12      77
21      78
15      79
12      80
21      81
15      82
21      83
21      84
21      84
24      85
15      85
24      86
21      86
24      87
21      87
21      87
24      88
24      90
24      90
24      90
21      90
18      90
18      91
15      91
24      92
24      92
21      92
21      92
21      92
18      92
24      93
24      93
18      93
15      93
24      94
24      94
24      95
24      96
18      96
21      97
18      98
96      99
96      100
96      99
96      98
96      97
96      100

   ;


proc nlin  data=fungi;
 	parms   Pmax=98 teta=15 ;d=6 ;

 	model germrate = Pmax*(1-(1/(1+((time/teta)**d))));
run;

proc nlin data=fungi method=newton;   
	parameters  Pmax=98 teta=15 ;d=6 ;  
	model germrate = Pmax*(1-(1/(1+((time/teta)**d)))); 
	output out=nlinout predicted=pred l95m=l95mean u95m=u95mean l95=l95ind u95=u95ind; 
run; 
proc print data=nlinout; 
run;

data filler;   
do time = 0 to 96 by 2;     
predict=1;     
output;   
end; 
run;

data fitthis; 
set fungi filler; 
run;

proc nlin data=fitthis method=newton;   
	parameters  Pmax=98 teta=15 ;d=6 ;  
	model germrate = Pmax*(1-(1/(1+((time/teta)**d))));   
	output out=nlinout predicted=pred l95m=l95mean u95m=u95mean; 
run; 

proc print data=nlinout(where=(predict=1)); run;

proc sort data = nlinout;
  by time;
run;

proc sgplot data=nlinout;

   scatter x=time y=germrate;
   series x=time y=pred;
   band upper=u95mean lower=l95mean x=time ;
run;

View solution in original post

4 REPLIES 4
djrisks
Barite | Level 11

Hi @RobinN , you just need to sort your graph by time before you do the plot. Please see the example below.

 

data fungi;
     input time germrate;
     datalines;
9       0
9       0
9       0
9       0
9       0
9       0
9       0
9       0
12      1
12      1
12      1
9       1
12      2
12      3
12      4
12      4
12      5
12      5
15      11
15      18
15      20
15      21
9       22
15      24
15      27
15      27
9       28
9       28
9       29
9       31
9       33
15      34
15      37
18      43
18      45
18      52
18      52
18      54
15      55
18      58
18      58
18      63
18      71
21      72
12      73
21      74
12      74
12      76
12      76
12      77
21      78
15      79
12      80
21      81
15      82
21      83
21      84
21      84
24      85
15      85
24      86
21      86
24      87
21      87
21      87
24      88
24      90
24      90
24      90
21      90
18      90
18      91
15      91
24      92
24      92
21      92
21      92
21      92
18      92
24      93
24      93
18      93
15      93
24      94
24      94
24      95
24      96
18      96
21      97
18      98
96      99
96      100
96      99
96      98
96      97
96      100

   ;


proc nlin  data=fungi;
 	parms   Pmax=98 teta=15 ;d=6 ;

 	model germrate = Pmax*(1-(1/(1+((time/teta)**d))));
run;

proc nlin data=fungi method=newton;   
	parameters  Pmax=98 teta=15 ;d=6 ;  
	model germrate = Pmax*(1-(1/(1+((time/teta)**d)))); 
	output out=nlinout predicted=pred l95m=l95mean u95m=u95mean l95=l95ind u95=u95ind; 
run; 
proc print data=nlinout; 
run;

data filler;   
do time = 0 to 96 by 2;     
predict=1;     
output;   
end; 
run;

data fitthis; 
set fungi filler; 
run;

proc nlin data=fitthis method=newton;   
	parameters  Pmax=98 teta=15 ;d=6 ;  
	model germrate = Pmax*(1-(1/(1+((time/teta)**d))));   
	output out=nlinout predicted=pred l95m=l95mean u95m=u95mean; 
run; 

proc print data=nlinout(where=(predict=1)); run;

proc sort data = nlinout;
  by time;
run;

proc sgplot data=nlinout;

   scatter x=time y=germrate;
   series x=time y=pred;
   band upper=u95mean lower=l95mean x=time ;
run;
djrisks
Barite | Level 11
I meant to say, sort your data instead of sort your graph...
RobinN
Fluorite | Level 6
This was quite easy and obvious. Many thanks for your quick help!
djrisks
Barite | Level 11
You're welcome! When you're doing series and band plots it's best to sort your data beforehand by the variable on the x-axis 🙂

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 469 views
  • 1 like
  • 2 in conversation