NLR procedure: user-specified estimates with bootstrap standard errors and CLs

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

NLR procedure: user-specified estimates with bootstrap standard errors and CLs

Ryan
Dear SPSS-L,
 
I've been reviewing the NLR procedure syntax documentation, and I can't seem to locate an option for obtaining user-specified estimates with respective standard errros/CLs within the procedure. Using the example below, is there a way to obtain log(RR) and its respective standard error/CLs within the procedure? The result of the COMPUTE statement I wrote does not seem show up in the output.
 
Is this simply not a capability of the procedure or am I going about this the wrong way?
 
Thanks,
 
Ryan
--
 
*Generate Data.
 set seed 34576598.
 new file.
 inp pro.
 loop ID= 1 to 10000.
     comp  x = rv.normal(0,1).
     if  (ID<=5000) group=0.
     if (ID>5000) group=1.
     comp #eta  = -1.5 + 1.2*group + 0.9*x.
     comp y = rv.bernoulli(1 / (1+ exp(-#eta))).
     end case.
   end loop.
 end file.
 end inp pro.
 exe.
 
*Fit model using LOGISTIC REGRESSION procedure.
 LOGISTIC REGRESSION VARIABLES y
   /METHOD=ENTER x group
   /PRINT=CI(95)
   /CRITERIA=PIN(0.05) POUT(0.10) ITERATE(20) CUT(0.5).

* Fit model using NonLinear Regression procedure.
MODEL PROGRAM  b0=0 b1=0 b2=0.
COMPUTE ETA = b0 + b1 * group + b2 * x .
COMPUTE PRED_=1 / (1 + exp(-ETA)).
COMPUTE LOSS_= -(y*ln(PRED_) + (1-y)*ln(1-PRED_)).
COMPUTE Log_RR_x_mean = ln((1 / exp(-(b0 + b2*(-.0208451919733551)))) / (1 / exp(-(b0 + b1 + b2*(-.0208451919733551))))).
CNLR  y
  /PRED PRED_
  /LOSS LOSS_
  /BOOTSTRAP.
Reply | Threaded
Open this post in threaded view
|

Re: NLR procedure: user-specified estimates with bootstrap standard errors and CLs

Ryan
If the answer to this question happens to be NO, then I would request that SPSS consider adding this functionality to the nonlinear procedure (I will contact SPSS to see if this capability exists, and if not, ask whether there are plans to upgrade the nonlinear procedure).
 
Being able to construct user-defined estimands to obtain standard errors about a statistic calculated from parameters estimated from a statistical model would be quite useful. Concretely, if one wanted to obtain confidence limits about a relative risk (e.g., group 1 v group 2 when covariate=<>) from estimates derived from logistic regression, a user-defined estimand that constructs a confidence interval about the log(RR) would be very useful. This is one of dozens of examples where a user-defined estimand would come in handy in the context of a generalized linear model and beyond.
 
Best,
 
Ryan
On Tue, Mar 26, 2013 at 9:03 AM, R B <[hidden email]> wrote:
Dear SPSS-L,
 
I've been reviewing the NLR procedure syntax documentation, and I can't seem to locate an option for obtaining user-specified estimates with respective standard errros/CLs within the procedure. Using the example below, is there a way to obtain log(RR) and its respective standard error/CLs within the procedure? The result of the COMPUTE statement I wrote does not seem show up in the output.
 
Is this simply not a capability of the procedure or am I going about this the wrong way?
 
Thanks,
 
Ryan
--
 
*Generate Data.
 set seed 34576598.
 new file.
 inp pro.
 loop ID= 1 to 10000.
     comp  x = rv.normal(0,1).
     if  (ID<=5000) group=0.
     if (ID>5000) group=1.
     comp #eta  = -1.5 + 1.2*group + 0.9*x.
     comp y = rv.bernoulli(1 / (1+ exp(-#eta))).
     end case.
   end loop.
 end file.
 end inp pro.
 exe.
 
*Fit model using LOGISTIC REGRESSION procedure.
 LOGISTIC REGRESSION VARIABLES y
   /METHOD=ENTER x group
   /PRINT=CI(95)
   /CRITERIA=PIN(0.05) POUT(0.10) ITERATE(20) CUT(0.5).

* Fit model using NonLinear Regression procedure.
MODEL PROGRAM  b0=0 b1=0 b2=0.
COMPUTE ETA = b0 + b1 * group + b2 * x .
COMPUTE PRED_=1 / (1 + exp(-ETA)).
COMPUTE LOSS_= -(y*ln(PRED_) + (1-y)*ln(1-PRED_)).
COMPUTE Log_RR_x_mean = ln((1 / exp(-(b0 + b2*(-.0208451919733551)))) / (1 / exp(-(b0 + b1 + b2*(-.0208451919733551))))).
CNLR  y
  /PRED PRED_
  /LOSS LOSS_
  /BOOTSTRAP.

Reply | Threaded
Open this post in threaded view
|

Re: NLR procedure: user-specified estimates with bootstrap standard errors and CLs

Ryan
In reply to this post by Ryan
For those taking note of the way I constructed log(RR), you might have noticed a slight error:
 
The group-specific probabilities should be calculated as
 
1 / [1 + exp(-eta_i)]
 
or
 
exp(eta_i) / [1 + exp(eta_i)]
 
Not worth the time or effort fixing the actual log(RR) COMPUTE statement since it doesn't produce anything. If the procedure has the capability, I will write back with the corrected log(RR) COMPUTE statement.

Apologies for the multiple posts but wanted to set the record straight.
 
Ryan

On Tue, Mar 26, 2013 at 9:03 AM, R B <[hidden email]> wrote:
Dear SPSS-L,
 
I've been reviewing the NLR procedure syntax documentation, and I can't seem to locate an option for obtaining user-specified estimates with respective standard errros/CLs within the procedure. Using the example below, is there a way to obtain log(RR) and its respective standard error/CLs within the procedure? The result of the COMPUTE statement I wrote does not seem show up in the output.
 
Is this simply not a capability of the procedure or am I going about this the wrong way?
 
Thanks,
 
Ryan
--
 
*Generate Data.
 set seed 34576598.
 new file.
 inp pro.
 loop ID= 1 to 10000.
     comp  x = rv.normal(0,1).
     if  (ID<=5000) group=0.
     if (ID>5000) group=1.
     comp #eta  = -1.5 + 1.2*group + 0.9*x.
     comp y = rv.bernoulli(1 / (1+ exp(-#eta))).
     end case.
   end loop.
 end file.
 end inp pro.
 exe.
 
*Fit model using LOGISTIC REGRESSION procedure.
 LOGISTIC REGRESSION VARIABLES y
   /METHOD=ENTER x group
   /PRINT=CI(95)
   /CRITERIA=PIN(0.05) POUT(0.10) ITERATE(20) CUT(0.5).

* Fit model using NonLinear Regression procedure.
MODEL PROGRAM  b0=0 b1=0 b2=0.
COMPUTE ETA = b0 + b1 * group + b2 * x .
COMPUTE PRED_=1 / (1 + exp(-ETA)).
COMPUTE LOSS_= -(y*ln(PRED_) + (1-y)*ln(1-PRED_)).
COMPUTE Log_RR_x_mean = ln((1 / exp(-(b0 + b2*(-.0208451919733551)))) / (1 / exp(-(b0 + b1 + b2*(-.0208451919733551))))).
CNLR  y
  /PRED PRED_
  /LOSS LOSS_
  /BOOTSTRAP.

Reply | Threaded
Open this post in threaded view
|

Re: NLR procedure: user-specified estimates with bootstrap standard errors and CLs

David Marso
Administrator
Hi Ryan,
I may be completely off base here, so apologies in advance if I'm hacking away at the wrong bush.
I'm not sure if this is what you want but note changing the DV to Log_Mean.
SAVE subcommand will give you the Predicted values and residuals (FWIW: derivatives as well).
OUTFILE dumps the bootstraps.
I am out of my depth WRT the down and dirty of calculating prediction intervals for such models,
possibly the bootstrapped parameter correlation matrix will be useful for this (unfortunately not saved).
(note I had to revert to v 11.5 for this as I only have base for v 21).

MODEL PROGRAM  b0=-1.5 b1=1.2 b2=.9.
COMPUTE ETA = b0 + b1 * group + b2 * x .
COMPUTE PRED_=1 / (1 + exp(-ETA)).
COMPUTE LOSS_= -(y*ln(PRED_) + (1-y)*ln(1-PRED_)).
COMPUTE Log_mean = ln((1 / exp(-(b0 + b2*(-.0208451919733551)))) / (1 / exp(-(b0 + b1 + b2*(-.0208451919733551))))).
CNLR  y
  /PRED Log_mean 
  /LOSS LOSS_
  /BOOTSTRAP
  /SAVE PRED RESID (res) LOSS DERIVATIVES
  /OUTFILE 'C:\TEMP\CNLR.sav'.

FORMATS ALL (F10.6).
LIST / CASES 1 TO 10.
GET FILE  'C:\TEMP\CNLR.sav'.
FORMATS ALL (F10.6).
LIST /CASES FROM 1 TO 10.

The variables are listed in the following order:

LINE   1: ID X GROUP Y LOG_MEAN RES

LINE   2: LOSS_ D.B0 D.B1 D.B2




      ID:   1.000000    .049859    .000000    .000000  -1.193250   1.193250
   LOSS_:    .214576    .193116    .000000    .009628

      ID:   2.000000   1.380842    .000000   1.000000  -1.193250   2.193250
   LOSS_:    .809476   -.554909    .000000   -.766241

      ID:   3.000000   1.395865    .000000   1.000000  -1.193250   2.193250
   LOSS_:    .801924   -.551535    .000000   -.769868

      ID:   4.000000   -.226706    .000000   1.000000  -1.193250   2.193250
   LOSS_:   1.851897   -.843061    .000000    .191127

      ID:   5.000000  -1.510986    .000000    .000000  -1.193250   1.193250
   LOSS_:    .056337    .054779    .000000   -.082771

      ID:   6.000000   -.511731    .000000    .000000  -1.193250   1.193250
   LOSS_:    .134252    .125630    .000000   -.064289

      ID:   7.000000   -.011302    .000000    .000000  -1.193250   1.193250
   LOSS_:    .204082    .184604    .000000   -.002086

      ID:   8.000000  -1.118568    .000000    .000000  -1.193250   1.193250
   LOSS_:    .079533    .076453    .000000   -.085518

      ID:   9.000000  -1.361134    .000000    .000000  -1.193250   1.193250
   LOSS_:    .064295    .062272    .000000   -.084760

      ID:  10.000000   -.046875    .000000    .000000  -1.193250   1.193250
   LOSS_:    .198193    .179788    .000000   -.008428


Number of cases read:  10    Number of cases listed:  10





        B0         B1         B2      LOSS_     NCASES     SAMPLE

 -1.475190   1.193250    .908624 5345.61674 10000.0000    .
 -1.495202   1.220873    .889375 5335.64728 6280.00000   1.000000
 -1.445949   1.215626    .943388 5350.00170 6329.00000   2.000000
 -1.468312   1.203480    .900569 5378.65717 6294.00000   3.000000
 -1.469155   1.208944    .873897 5383.48817 6323.00000   4.000000
 -1.425803   1.185862    .879732 5430.83775 6320.00000   5.000000
 -1.442727   1.142812    .891361 5396.24806 6354.00000   6.000000
 -1.484476   1.204209    .851382 5370.02387 6297.00000   7.000000
 -1.429901   1.083561    .909031 5399.71827 6358.00000   8.000000
 -1.449031   1.154400    .918483 5370.73522 6335.00000   9.000000


Number of cases read:  10    Number of cases listed:  10
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
Reply | Threaded
Open this post in threaded view
|

Re: NLR procedure: user-specified estimates with bootstrap standard errors and CLs

Ryan
Thanks for your code, David. I will investigate them closely.
 
The following three messages posted by Dale M. on SAS-L basically sum up why I was attempting to use the nonlinear regression procedure in SPSS.  For those interested in estimating RRs and their confidence intervals, I VERY STRONGLY recommend to read these posts carefully. I learned a great deal from them years ago.
 
 
 
Although I was able to fit a logistic regression with a categorical and continuous predictor using the nonlinear regression procedure in SPSS (as demonstrated in the code I posted), the purpose was not to replicate a model which can be easily employed using a couple of procedures (e.g., LOGISTIC, GENLIN). I was not able to achieve my objective: to obtain confidence limits about the log(RR).
 
Having said that, it has made me wonder whether it's possible to fit  more complex models using this procedure. I will play around with the procedure as time permits.
 
Best,
 
Ryan
 
On Tue, Mar 26, 2013 at 4:44 PM, David Marso <[hidden email]> wrote:
Hi Ryan,
I may be completely off base here, so apologies in advance if I'm hacking
away at the wrong bush.
I'm not sure if this is what you want but note changing the DV to Log_Mean.
SAVE subcommand will give you the Predicted values and residuals (FWIW:
derivatives as well).
OUTFILE dumps the bootstraps
I am out of my depth WRT the down and dirty of calculating prediction
intervals for such models,
possibly the bootstrapped parameter correlation matrix will be useful for
this (unfortunately not saved).
(note I had to revert to v 11.5 for this as I only have base for v 21).

MODEL PROGRAM  b0=-1.5 b1=1.2 b2=.9.
COMPUTE ETA = b0 + b1 * group + b2 * x .
COMPUTE PRED_=1 / (1 + exp(-ETA)).
COMPUTE LOSS_= -(y*ln(PRED_) + (1-y)*ln(1-PRED_)).
COMPUTE *Log_mean* = ln((1 / exp(-(b0 + b2*(-.0208451919733551)))) / (1 /
exp(-(b0 + b1 + b2*(-.0208451919733551))))).
CNLR  y
  /PRED *Log_mean*
  /LOSS LOSS_
  /BOOTSTRAP
  /*SAVE PRED RESID (res) LOSS DERIVATIVES*
  /*OUTFILE 'C:\TEMP\CNLR.sav'*.

FORMATS ALL (F10.6).
LIST / CASES 1 TO 10.
GET FILE  'C:\TEMP\CNLR.sav'.
FORMATS ALL (F10.6).
LIST /CASES FROM 1 TO 10.

The variables are listed in the following order:

LINE   1: ID X GROUP Y *LOG_MEAN* RES

LINE   2: LOSS_ D.B0 D.B1 D.B2




      ID:   1.000000    .049859    .000000    .000000  *-1.193250*
1.193250
   LOSS_:    .214576    .193116    .000000    .009628

      ID:   2.000000   1.380842    .000000   1.000000  -1.193250   2.193250
   LOSS_:    .809476   -.554909    .000000   -.766241

      ID:   3.000000   1.395865    .000000   1.000000  -1.193250   2.193250
   LOSS_:    .801924   -.551535    .000000   -.769868

      ID:   4.000000   -.226706    .000000   1.000000  -1.193250   2.193250
   LOSS_:   1.851897   -.843061    .000000    .191127

      ID:   5.000000  -1.510986    .000000    .000000  -1.193250   1.193250
   LOSS_:    .056337    .054779    .000000   -.082771

      ID:   6.000000   -.511731    .000000    .000000  -1.193250   1.193250
   LOSS_:    .134252    .125630    .000000   -.064289

      ID:   7.000000   -.011302    .000000    .000000  -1.193250   1.193250
   LOSS_:    .204082    .184604    .000000   -.002086

      ID:   8.000000  -1.118568    .000000    .000000  -1.193250   1.193250
   LOSS_:    .079533    .076453    .000000   -.085518

      ID:   9.000000  -1.361134    .000000    .000000  -1.193250   1.193250
   LOSS_:    .064295    .062272    .000000   -.084760

      ID:  10.000000   -.046875    .000000    .000000  -1.193250   1.193250
   LOSS_:    .198193    .179788    .000000   -.008428


Number of cases read:  10    Number of cases listed:  10





        B0         B1         B2      LOSS_     NCASES     SAMPLE

 -1.475190   1.193250    .908624 5345.61674 10000.0000    .
 -1.495202   1.220873    .889375 5335.64728 6280.00000   1.000000
 -1.445949   1.215626    .943388 5350.00170 6329.00000   2.000000
 -1.468312   1.203480    .900569 5378.65717 6294.00000   3.000000
 -1.469155   1.208944    .873897 5383.48817 6323.00000   4.000000
 -1.425803   1.185862    .879732 5430.83775 6320.00000   5.000000
 -1.442727   1.142812    .891361 5396.24806 6354.00000   6.000000
 -1.484476   1.204209    .851382 5370.02387 6297.00000   7.000000
 -1.429901   1.083561    .909031 5399.71827 6358.00000   8.000000
 -1.449031   1.154400    .918483 5370.73522 6335.00000   9.000000


Number of cases read:  10    Number of cases listed:  10




-----
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
--
View this message in context: http://spssx-discussion.1045642.n5.nabble.com/NLR-procedure-user-specified-estimates-with-bootstrap-standard-errors-and-CLs-tp5719088p5719093.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD