turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- Analytics
- /
- Stat Procs
- /
- Size effects

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

03-12-2016 04:41 AM

Hello

How to find the fish size effects on its digestion rate (slope value) using proc satatement?

I can find the slop and intercepet of each group using proc reg. But I have two groups and both produced different slope value. I know this change is becasue of fish size (one group has 30g size fish, another has 150g size fish), so is there any way to find the effect of fish size (exponent)?

Accepted Solutions

Solution

03-14-2016
03:27 AM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to UmarKhan

03-13-2016 10:43 PM

You must fit an intercept for every group:

```
data fish;
set xl.'Sir Nadir$'n;
rename x=t y=S_t;
label y="S(t)" x="t";
run;
proc nlin data=fish;
parms slope_0 = 1.0 exponent = 1.0
intercept_1 = 1.5
intercept_2 = 1.5
intercept_3 = 1.5
intercept_4 = 1.5
intercept_5 = 1.5
intercept_6 = 1.5 ;
slope = slope_0*fish_size**exponent;
group_1 = (group = 1);
group_2 = (group = 2);
group_3 = (group = 3);
group_4 = (group = 4);
group_5 = (group = 5);
group_6 = (group = 6);
model S_t =
intercept_1*group_1 +
intercept_2*group_2 +
intercept_3*group_3 +
intercept_4*group_4 +
intercept_5*group_5 +
intercept_6*group_6 -
slope*t;
output out=fishPred predicted=p_S_t residual=r_S_t;
run;
proc sort data=fishPred; by group t fish_size; run;
title;
proc sgplot data=fishPred;
scatter y=S_t x=t / group=group;
series y=p_S_t x=t / group=group lineattrs=(pattern=Solid)
curvelabel curvelabelpos=end;
run;
```

Approx Approximate 95% Confidence Parameter Estimate Std Error Limits slope_0 0.00114 0.000405 0.000348 0.00194 exponent 0.4911 0.0725 0.3485 0.6337 intercept_1 1.2018 0.0284 1.1459 1.2578 intercept_2 0.9589 0.0276 0.9046 1.0131 intercept_3 0.7986 0.0258 0.7478 0.8494 intercept_4 1.8081 0.0283 1.7524 1.8638 intercept_5 1.4271 0.0290 1.3700 1.4842 intercept_6 1.1312 0.0268 1.0785 1.1838

PG

All Replies

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to UmarKhan

03-12-2016 05:58 AM

You can include fish size in the model.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to UmarKhan

03-12-2016 06:44 AM

It is the proc statement;

Proc reg data=abcd;

Model y=x;

Run;

So where to insert the fish size here? The relationship between slope and fish size is mostly described by simple power function.

Proc reg data=abcd;

Model y=x;

Run;

So where to insert the fish size here? The relationship between slope and fish size is mostly described by simple power function.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to UmarKhan

03-12-2016 11:38 AM

I'm not sure what you mean. Can you write out the equation your trying to model?

I was suggesting you add size into model, but it sounds like you want a more complex model.

Model Y = x size;

I was suggesting you add size into model, but it sounds like you want a more complex model.

Model Y = x size;

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Reeza

03-12-2016 11:57 AM

Dear Reeza,

Generally we run first proc reg (model y=x) etc to find the slop value. Suppose I have two sample of 35g and 150g. I find the digestion rate (slope) for each group. After finding slope values, I plot the slope values at y-axis and fish body weight (W) at x-axis and run the power trending (see the fig. below). But I want to modify my model y=x to also calculate the effect of body mass of fish on slope value.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to UmarKhan

03-12-2016 12:01 PM

Try the suggested code above then.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Reeza

03-12-2016 12:17 PM - edited 03-12-2016 12:19 PM

Dear Reeza,

I try but not working. I attached the xlsx file, you can try it too. As I told you that I run the simple linear regression and then plot the generated slope values against the fish weight to find the mass exponent (effect of fish size on slope value).

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to UmarKhan

03-12-2016 12:58 PM

I don't like to download attachments, if you'd like further assistance from me please post your code and log. Otherwise someone else will help out.

Here's a macro that will transform your data step into a data set code that can be pasted into the window here.

http://blogs.sas.com/content/sastraining/2016/03/11/jedi-sas-tricks-data-to-data-step-macro/

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Reeza

03-12-2016 01:08 PM

Deare Reeza,

Unfortunately I don't know the method you shared for data sharing. We have to wait for someone else then to help me in this case.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to UmarKhan

03-12-2016 02:29 PM

In your data, is Y = S(t), X = t and fish_size = W ?

PG

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to PGStats

03-13-2016 04:07 AM

Yes, it is like that (Y = S(t), X = t and fish_size = W). I want to find the fish size effect on slope value (digestion rate). You can see in my above shared graph.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to PGStats

03-13-2016 02:31 PM - edited 03-13-2016 02:41 PM

Dears,

I use this equation to find the intercept and slope for my data; St=a- slope*t and then I used this: slope=slope*W^b to find the effect of fish size on slope (b).

I need sas proc for this.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to UmarKhan

03-13-2016 05:04 PM

You are looking for nonlinear regression. I renamed your data file **Fish size effects.xlsx** and ran:

```
libname xl Excel "&sasforum\datasets\Fish size effect.xlsx" access=readonly;
data fish;
set xl.'Sheet1$'n;
rename x=t y=S_t;
label y="S(t)" x="t";
run;
proc nlin data=fish;
parms slope_0 = 1.0 intercept_1 = 1.75 intercept_2 = 0.75 exponent = 1.0 ;
slope = slope_0*fish_size**exponent;
group_1 = (group = 1);
group_2 = (group = 2);
model S_t = intercept_1*group_1 + intercept_2*group_2 - slope*t;
output out=fishPred predicted=p_S_t;
run;
proc sort data=fishPred; by group t; run;
title;
proc sgplot data=fishPred;
scatter y=S_t x=t / group=group;
series y=p_S_t x=t / group=group;
run;
```

I got this fit (the vertical transitions represent the effect of fish size for each value of t):

PG

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to PGStats

03-13-2016 05:42 PM - edited 03-14-2016 03:29 AM

Thanks PG Stats,

I run like that:

FILENAME CSV "/folders/myfolders/Sir nadir.csv" TERMSTR=CRLF;

PROC IMPORT DATAFILE=CSV

OUT=geumar2

DBMS=CSV

REPLACE;

RUN;

title 'geumar';

data group;

set geumar2;

run;

data group;

set geumar2;

rename x=t y=S_t;

label y="S(t)" x="t";

run;

proc nlin data=exp;

parms slope_0 = 1.0 intercept_1 = 1.75 intercept_2 = 0.75 exponent = 1.0 ;

slope = slope_0*fish_size**exponent;

group_1 = (group = 1);

group_2 = (group = 2);

model S_t = intercept_1*group_1 + intercept_2*group_2 - slope*t;

output out=fishPred predicted=p_S_t;

run;

it doesn't give any error but it doesn't converge.

WARNING: Step size shows no improvement.

WARNING: PROC NLIN failed to converge.

I am sharing a file which has total 6 groups, I edited your constricted proc to include others group too but the mass exponent is -48. According to my data analysis done with hands, it should be near to 0.55.

Solution

03-14-2016
03:27 AM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to UmarKhan

03-13-2016 10:43 PM

You must fit an intercept for every group:

```
data fish;
set xl.'Sir Nadir$'n;
rename x=t y=S_t;
label y="S(t)" x="t";
run;
proc nlin data=fish;
parms slope_0 = 1.0 exponent = 1.0
intercept_1 = 1.5
intercept_2 = 1.5
intercept_3 = 1.5
intercept_4 = 1.5
intercept_5 = 1.5
intercept_6 = 1.5 ;
slope = slope_0*fish_size**exponent;
group_1 = (group = 1);
group_2 = (group = 2);
group_3 = (group = 3);
group_4 = (group = 4);
group_5 = (group = 5);
group_6 = (group = 6);
model S_t =
intercept_1*group_1 +
intercept_2*group_2 +
intercept_3*group_3 +
intercept_4*group_4 +
intercept_5*group_5 +
intercept_6*group_6 -
slope*t;
output out=fishPred predicted=p_S_t residual=r_S_t;
run;
proc sort data=fishPred; by group t fish_size; run;
title;
proc sgplot data=fishPred;
scatter y=S_t x=t / group=group;
series y=p_S_t x=t / group=group lineattrs=(pattern=Solid)
curvelabel curvelabelpos=end;
run;
```

Approx Approximate 95% Confidence Parameter Estimate Std Error Limits slope_0 0.00114 0.000405 0.000348 0.00194 exponent 0.4911 0.0725 0.3485 0.6337 intercept_1 1.2018 0.0284 1.1459 1.2578 intercept_2 0.9589 0.0276 0.9046 1.0131 intercept_3 0.7986 0.0258 0.7478 0.8494 intercept_4 1.8081 0.0283 1.7524 1.8638 intercept_5 1.4271 0.0290 1.3700 1.4842 intercept_6 1.1312 0.0268 1.0785 1.1838

PG