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
- /
- multivariate Non linear regression

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
- Highlight
- Email to a Friend
- Report Inappropriate Content

05-24-2017 03:49 PM - edited 05-24-2017 03:52 PM

Hi All,

I am trying to use NLIN Model (Non linear regression) using Sas guide.

My model has many covariats. When using the Sas Wizard, it's written that the number of explanatory variable is limited to 1 (not sure why..). However, when trying to update the code, it allowed me to add two more covariates but when adding dozens, I get the message: 'Zero observations could be evaluated' and the model did not predict anything.

Do you have any idea how to make it work?

Thanks a lot in advance!

Accepted Solutions

Solution

a month ago

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

a month ago

Although your title says "nonlinear regression," this looks like a LINEAR equation with constrained coefficients > 0.

You can put the bounds on a single statement:

BOUNDS a b ... az > 0;

Without the real code, there's not much to say. However, here is a simulated linear regression data set that contains 20 variables and an intercept. PROC NLIN has no problems finding the parameter estimates. Maybe you can use this example to help guide you. Good luck.

```
%let N = 100000; /* Specify sample size */
%let nCont = 20; /* Specify the number of continuous variables */
data SimReg1(keep= Y x:);
call streaminit(54321); /* set the random number seed */
array x[&nCont]; /* explanatory vars are named x1-x&nCont */
/* 1. Specify model coefficients. You can hard-code values such as
array beta[0:&nCont] _temporary_ (-4 2 -1.33 1 -0.8 0.67 -0.57 0.5 -0.44 0.4 -0.36);
or you can use a formula such as the following */
array beta[0:&nCont] beta0-beta&nCont;
do j = 0 to &nCont;
beta[j] = round(4*rand("uniform"), 0.1); /* formula for beta[j] */
end;
put (beta[*]) (=); /* put each element of array */
do i = 1 to &N; /* for each observation in the sample */
do j = 1 to dim(x);
x[j] = rand("Normal"); /* 2. Simulate explanatory variables */
end;
eta = beta[0]; /* model = intercept term */
do j = 1 to &nCont;
eta = eta + beta[j] * x[j]; /* + sum(beta[j]*x[j]) */
end;
epsilon = rand("Normal", 0, 1.5); /* 3. Specify error distrib */
Y = eta + epsilon; /* 4. Y = model + error */
output;
end;
run;
ods select ParameterEstimates;
proc nlin data=SimReg1;
parms b1-b20 =1;
bounds b1-b20 > 0;
model Y = b1*x1 + b2*x2 + b3*x3 + b4*x4 + b5*x5 +
b6*x6 + b7*x7 + b8*x8 + b9*x9 + b10*x10 +
b11*x11 + b12*x12 + b13*x13 + b14*x14 + b15*x15 +
b16*x16 + b17*x17 + b18*x18 + b19*x19 + b20*x20;
run;
```

All Replies

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

05-24-2017 03:59 PM

Paste the "updated code" that you typed in. It's possible that that model cannot be evaluated on this data. For example, a model that has the term "log(x)" doesn't make sense if x is always negative. Sample data would be helpful, too.

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

a month ago

Hi,

I don't have access to the code at the moment, but I changed the generated code in 4 sections to change it to mulrivariates.

when I added a total of 15 covariates it did work. But from 16 it gave me the warning and did not work.

These are the changes I made:

(cov1 = name of the first covariate)

Select

1. a*"cov1"n ; b*"cov2"n ; ...az*"cov52"n;

2. "dependentVar1"n = a*"cov1"n + b*"cov2"n + c*"cov3"n + ... + az*"cov52"n

3. a = 0.001 b= 0.001 c= 0.001....az = 0.001;

4.

Bounuds a > 0;

Bounuds b > 0;............

Bounuds az > 0;

Regarding the input: there are about 100 vectors which describe amounts - integers between 1 and 10,000 while some of them are very sparse (mostly zeros).

I hope this is enought information.

Thanks!

Solution

a month ago

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

a month ago

Although your title says "nonlinear regression," this looks like a LINEAR equation with constrained coefficients > 0.

You can put the bounds on a single statement:

BOUNDS a b ... az > 0;

Without the real code, there's not much to say. However, here is a simulated linear regression data set that contains 20 variables and an intercept. PROC NLIN has no problems finding the parameter estimates. Maybe you can use this example to help guide you. Good luck.

```
%let N = 100000; /* Specify sample size */
%let nCont = 20; /* Specify the number of continuous variables */
data SimReg1(keep= Y x:);
call streaminit(54321); /* set the random number seed */
array x[&nCont]; /* explanatory vars are named x1-x&nCont */
/* 1. Specify model coefficients. You can hard-code values such as
array beta[0:&nCont] _temporary_ (-4 2 -1.33 1 -0.8 0.67 -0.57 0.5 -0.44 0.4 -0.36);
or you can use a formula such as the following */
array beta[0:&nCont] beta0-beta&nCont;
do j = 0 to &nCont;
beta[j] = round(4*rand("uniform"), 0.1); /* formula for beta[j] */
end;
put (beta[*]) (=); /* put each element of array */
do i = 1 to &N; /* for each observation in the sample */
do j = 1 to dim(x);
x[j] = rand("Normal"); /* 2. Simulate explanatory variables */
end;
eta = beta[0]; /* model = intercept term */
do j = 1 to &nCont;
eta = eta + beta[j] * x[j]; /* + sum(beta[j]*x[j]) */
end;
epsilon = rand("Normal", 0, 1.5); /* 3. Specify error distrib */
Y = eta + epsilon; /* 4. Y = model + error */
output;
end;
run;
ods select ParameterEstimates;
proc nlin data=SimReg1;
parms b1-b20 =1;
bounds b1-b20 > 0;
model Y = b1*x1 + b2*x2 + b3*x3 + b4*x4 + b5*x5 +
b6*x6 + b7*x7 + b8*x8 + b9*x9 + b10*x10 +
b11*x11 + b12*x12 + b13*x13 + b14*x14 + b15*x15 +
b16*x16 + b17*x17 + b18*x18 + b19*x19 + b20*x20;
run;
```