SPSS program: Confidence Interval for Cohen's d Based on the Noncentral t-Distribution

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

SPSS program: Confidence Interval for Cohen's d Based on the Noncentral t-Distribution

valferes

I am pleased to inform that a new program

Confidence Interval for Cohen's d Based on the Noncentral t-Distribution

has been added to SPSS Syntax Files

http://gaius.fpce.uc.pt/niips/spss_prc/index.htm#meta

 

Valentim R. Alferes
[hidden email]
http://gaius.fpce.uc.pt/niips/

===================== 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
Reply | Threaded
Open this post in threaded view
|

Re: SPSS program: Confidence Interval for Cohen's d Based on the Noncentral t-Distribution

David Marso
Administrator
Valentim,
  Do you care to elaborate on what/why is going on with this beginning of the code?
Sometimes comments in code can be useful!
Why all those EXECUTE statements?
I'm surprised it works at all without an exe after the end loop prior to the GET FILE.
other than that it looks like you are generating 2 million cases of constant data?
Later sorting it twice.  Seriously?
Why?  Maybe I'm missing something?
Surely there are more direct/efficient ways to achieve this?
OTOH, since we don't know WTF the reason why it was written this way/intention it is difficult to make any cogent proposals.
As currently coded I am left feeling compelled to extract my eyeballs with a sharpened spoon!
David

begin data.
0.84 20 15
end data.

* Enter confidence level (by default, CL=95%).
compute CL=95.
execute.

loop NCP=0 to 2*10**6.
xsave outfile='%temp%\file1'.
end loop.
get file='%temp%\file1'.
compute df=N1+N2-2.
compute tobs=d/sqr(1/N1+1/N2).
compute NCP=NCP-10**6.
compute NCP=NCP/10**4.
compute p1=((100-CL)/100)/2.
compute p2=1-p1.
compute prob=ncdf.t(tobs,df,NCP).
compute dif1=abs(p1-prob).
execute.
sort cases by dif1(a).
if ($casenum=1) NCPupper=NCP.
execute.
compute dif2=abs(p2-prob).
execute.
sort cases by dif2(a).
if ($casenum=1) NCPlower=NCP.
execute.
compute w=1.
execute.
........
more bizarre stuff....
----
valferes wrote
I am pleased to inform that a new program

Confidence Interval
for Cohen's d Based on the Noncentral t-Distribution

has been added to SPSS Syntax Files

http://gaius.fpce.uc.pt/niips/spss_prc/index.htm#meta

 

Valentim R. Alferes

[hidden email]

http://gaius.fpce.uc.pt/niips/ 

     
=====================
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
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: SPSS program: Confidence Interval for Cohen's d Based on the Noncentral t-Distribution‏

valferes
In reply to this post by valferes

David,

Given that SPSS has not the “Inverse Noncentral t Cumulative Distribution Function”, there is only one way to obtain the accurate value ​​of a noncentrality parameter (NCP) for a given probability: to use the “Noncentral t Cumulative Distribution Function” and iteratively search for the NCP. This is what the code does!

The number of cases generated is a simple matter of precision (with the current numbers, we obtain accurate NCPs up to the fourth decimal place). The two “sort commands” are needed because there are two NCP: for p = .025 and p = .975.

I hope that SPSS 23 will include the “Inverse Noncentral t cdf”, as is the case of MATLAB (see http://www.mathworks.com/help/stats/nctinv.html)

 

Best regards,

Valentim

http://gaius.fpce.uc.pt/niips/

http://gaius.fpce.uc.pt/niips/spss_prc/index.htm

===================== 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
Reply | Threaded
Open this post in threaded view
|

Re: SPSS program: Confidence Interval for Cohen's d Based on the Noncentral t-Distribution‏

Rich Ulrich
I needed an inverse, back in the days when computers were more finite, so
I found the other way.

The other way to get the inverse from the cumulative distribution is to
interpolate (using transformed scales that produce approximate linearity)
and iterate.  Two iterations should give you the 4th decimal.

--
Rich Ulrich


Date: Mon, 28 Jul 2014 19:01:28 +0000
From: [hidden email]
Subject: Re: SPSS program: Confidence Interval for Cohen's d Based on the Noncentral t-Distribution‏
To: [hidden email]

David,

Given that SPSS has not the “Inverse Noncentral t Cumulative Distribution Function”, there is only one way to obtain the accurate value ​​of a noncentrality parameter (NCP) for a given probability: to use the “Noncentral t Cumulative Distribution Function” and iteratively search for the NCP. This is what the code does!

The number of cases generated is a simple matter of precision (with the current numbers, we obtain accurate NCPs up to the fourth decimal place). The two “sort commands” are needed because there are two NCP: for p = .025 and p = .975.

I hope that SPSS 23 will include the “Inverse Noncentral t cdf”, as is the case of MATLAB (see http://www.mathworks.com/help/stats/nctinv.html)

 ...

===================== 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
Reply | Threaded
Open this post in threaded view
|

Re: SPSS program: Confidence Interval for Cohen's d Based on the Noncentral t-Distribution‏

valferes
Dear Rich Ulrich,

I would be very grateful if you could show me your solution to the same problem:

 

* My data: t observed and degrees of freedom.

data list list/tobs(f12.10) df(f8.0).

begin data.

2.4592681838 33

end data.

* Problem: Find the noncentrality parameters for p1=.025 and p2=.975.

 

My code is here and the illustrative output is here.

 

Sincerely,

Valentim R. Alferes

http://gaius.fpce.uc.pt/niips/
 


Date: Tue, 29 Jul 2014 00:45:37 -0400
From: [hidden email]
Subject: Re: SPSS program: Confidence Interval for Cohen's d Based on the Noncentral t-Distribution‏
To: [hidden email]

I needed an inverse, back in the days when computers were more finite, so
I found the other way.

The other way to get the inverse from the cumulative distribution is to
interpolate (using transformed scales that produce approximate linearity)
and iterate.  Two iterations should give you the 4th decimal.

--
Rich Ulrich


Date: Mon, 28 Jul 2014 19:01:28 +0000
From: [hidden email]
Subject: Re: SPSS program: Confidence Interval for Cohen's d Based on the Noncentral t-Distribution‏
To: [hidden email]

David,

Given that SPSS has not the “Inverse Noncentral t Cumulative Distribution Function”, there is only one way to obtain the accurate value ​​of a noncentrality parameter (NCP) for a given probability: to use the “Noncentral t Cumulative Distribution Function” and iteratively search for the NCP. This is what the code does!

The number of cases generated is a simple matter of precision (with the current numbers, we obtain accurate NCPs up to the fourth decimal place). The two “sort commands” are needed because there are two NCP: for p = .025 and p = .975.

I hope that SPSS 23 will include the “Inverse Noncentral t cdf”, as is the case of MATLAB (see http://www.mathworks.com/help/stats/nctinv.html)

 ...

===================== 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
===================== 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
Reply | Threaded
Open this post in threaded view
|

Re: SPSS program: Confidence Interval for Cohen's d Based on the Noncentral t-Distribution‏

David Marso
Administrator
Why not build some loops rather than going at it with a sledge hammer by building 2 million cases?
Also get rid of the EXECUTE statements!
--
valferes wrote
Dear Rich Ulrich,I would be very grateful if you could show me your solution to the same problem:
 
* My data: t observed and degrees of freedom.
data list list/tobs(f12.10) df(f8.0).
begin data.
2.4592681838 33
end data.

* Problem: Find the noncentrality parameters for p1=.025 and p2=.975.
My code is here and the illustrative output is here.
Sincerely,
Valentim R. Alferes
http://gaius.fpce.uc.pt/niips/ 
  Date: Tue, 29 Jul 2014 00:45:37 -0400
From: [hidden email]
Subject: Re: SPSS program: Confidence Interval for Cohen's d Based on the Noncentral t-Distribution‏
To: [hidden email]



 I needed an inverse, back in the days when computers were more finite, so
I found the other way.

The other way to get the inverse from the cumulative distribution is to
interpolate (using transformed scales that produce approximate linearity)
and iterate.  Two iterations should give you the 4th decimal.

--
Rich Ulrich

Date: Mon, 28 Jul 2014 19:01:28 +0000
From: [hidden email]
Subject: Re: SPSS program: Confidence Interval for Cohen's d Based on the Noncentral t-Distribution‏
To: [hidden email]



 David,Given that SPSS has not the “Inverse Noncentral t Cumulative Distribution Function”, there is only one way to obtain the accurate value ​​of a noncentrality parameter (NCP) for a given probability: to use the “Noncentral t Cumulative Distribution Function” and iteratively search for the NCP. This is what the code does!The number of cases generated is a simple matter of precision (with the current numbers, we obtain accurate NCPs up to the fourth decimal place). The two “sort commands” are needed because there are two NCP: for p = .025 and p = .975.I hope that SPSS 23 will include the “Inverse Noncentral t cdf”, as is the case of MATLAB (see http://www.mathworks.com/help/stats/nctinv.html) ...===================== 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    

=====================
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
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: SPSS program: Confidence Interval for Cohen's d Based on the Noncentral t-Distribution‏

valferes
David and Rich,

The code is entirely correct and provides reliable results (compare with ESCI or MOTE outputs). Moreover, it is done so that any novice user can get the CI via a simplified input: d, N1 and N2.
The time it takes to run the syntax is negligible (on my computer, no more than 40 seconds).


Anyway, I'm waiting for one of two solutions:
(a) Inverse Noncentral t cdf available in IBM SPSS 23;
(b) The solution found by
Rich.

Sincerely,

Valentim
 

http://gaius.fpce.uc.pt/niips/  


 

 
 

 
> Date: Tue, 29 Jul 2014 05:46:56 -0700

> From: [hidden email]
> Subject: Re: SPSS program: Confidence Interval for Cohen's d Based on the Noncentral t-Distribution‏
> To: [hidden email]
>
> Why not build some loops rather than going at it with a sledge hammer by
> building 2 million cases?
> Also get rid of the EXECUTE statements!
> --
>
> valferes wrote
> > Dear Rich Ulrich,I would be very grateful if you could show me your
> > solution to the same problem:
> >
> > * My data: t observed and degrees of freedom.
> > data list list/tobs(f12.10) df(f8.0).
> > begin data.
> > 2.4592681838 33
> > end data.
> >
> > * Problem: Find the noncentrality parameters for p1=.025 and p2=.975.
> > My code is here and the illustrative output is here.
> > Sincerely,
> > Valentim R. Alferes
> > http://gaius.fpce.uc.pt/niips/
> > Date: Tue, 29 Jul 2014 00:45:37 -0400
> > From:
>
> > rich-ulrich@
>
> > Subject: Re: SPSS program: Confidence Interval for Cohen's d Based on the
> > Noncentral t-Distribution‏
> > To:
>
> > SPSSX-L@.UGA
>
> >
> >
> >
> > I needed an inverse, back in the days when computers were more finite, so
> > I found the other way.
> >
> > The other way to get the inverse from the cumulative distribution is to
> > interpolate (using transformed scales that produce approximate linearity)
> > and iterate. Two iterations should give you the 4th decimal.
> >
> > --
> > Rich Ulrich
> >
> > Date: Mon, 28 Jul 2014 19:01:28 +0000
> > From:
>
> > valferes@
>
> > Subject: Re: SPSS program: Confidence Interval for Cohen's d Based on the
> > Noncentral t-Distribution‏
> > To:
>
> > SPSSX-L@.UGA
>
> >
> >
> >
> > David,Given that SPSS has not the “Inverse Noncentral t Cumulative
> > Distribution Function”, there is only one way to obtain the accurate value
> > ​​of a noncentrality parameter (NCP) for a given probability: to use the
> > “Noncentral t Cumulative Distribution Function” and iteratively search for
> > the NCP. This is what the code does!The number of cases generated is a
> > simple matter of precision (with the current numbers, we obtain accurate
> > NCPs up to the fourth decimal place). The two “sort commands” are needed
> > because there are two NCP: for p = .025 and p = .975.I hope that SPSS 23
> > will include the “Inverse Noncentral t cdf”, as is the case of MATLAB (see
> > http://www.mathworks.com/help/stats/nctinv.html) ...=====================
> > To manage your subscription to SPSSX-L, send a message to
>
> > LISTSERV@.UGA
>
> > (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
> >
> > =====================
> > To manage your subscription to SPSSX-L, send a message to
>
> > LISTSERV@.UGA
>
> > (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
>
>
>
>
>
> -----
> 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/SPSS-program-Confidence-Interval-for-Cohen-s-d-Based-on-the-Noncentral-t-Distribution-tp5726831p5726844.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
>
>
>
>
===================== 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
Reply | Threaded
Open this post in threaded view
|

Re: SPSS program: Confidence Interval for Cohen's d Based on the Noncentral t-Distribution‏

David Marso
Administrator
40 seconds?
This runs in about 1/10th of a second and gives as much accuracy as could be desired!
-----
DEFINE NCPMacro (d !TOKENS(1) / N1 !TOKENS(1) /N2 !TOKENS(1) /CL !TOKENS(1) !DEFAULT (95) ).
INPUT PROGRAM.
LOOP #=1 TO 1.
END CASE.
END LOOP.
END FILE.
END INPUT PROGRAM.
COMPUTE CL=!CL.
COMPUTE df=!N1+!N2-2.
COMPUTE tobs=!d/sqr(1/!N1+1/!N2).
COMPUTE p1=1-((100-!CL)/100)/2.
SET MXLOOPS=100.
COMPUTE epsilon=.0000001.
VECTOR NCPs(2).
LOOP #=1 TO 2.
+  COMPUTE minabsdif=1.
+  COMPUTE bottomNCP=-10.
+  COMPUTE topNCP=10.
+  COMPUTE newdelta=1.
+  COMPUTE incr=1.
+  IF #=1 P=P1.
+  IF #=2 P=1-P1.
+  LOOP.
+    LOOP NCPvalue= bottomNCP TO topNCP BY incr.
+      COMPUTE delta=newdelta.
+      COMPUTE prob=ncdf.t(tobs,df,NCPvalue).
+      COMPUTE newdelta=abs(p-prob).
+      DO IF newdelta LT minabsdif.
+        COMPUTE minabsdif=newdelta.
+        COMPUTE minNCP=NCPvalue.
+      END IF.
+    END LOOP.
+    COMPUTE bottomNCP=minNCP-incr.
+    COMPUTE topNCP=minNCP+incr.
+    COMPUTE incr=incr/10.
+  END LOOP IF delta LE epsilon.
+  COMPUTE NCPs(#)=minNCP.
PRINT minNCP (F10.6).
END LOOP.
PRINT /NCPs1 NCPs2 (2F12.8).
EXECUTE.
!ENDDEFINE.
NCPMacro d=0.84 N1=20 N2=15  .

* result  .39506810  4.48934000

valferes wrote
David and Rich,

The code is entirely correct and provides reliable results (compare with ESCI
or MOTE outputs).
Moreover, it is done so that any novice user can get
the CI via a simplified input: d, N1
and N2.

The time it takes to run the syntax is negligible (on my computer, no more
than 40 seconds).




Anyway, I'm waiting for one of two solutions:

(a) Inverse Noncentral t cdf available in
IBM SPSS 23;

(b) The solution found
by Rich.

Sincerely,


Valentim


 
http://gaius.fpce.uc.pt/niips/ 


 

 
 
 
> Date: Tue, 29 Jul 2014 05:46:56 -0700
> From: [hidden email]
> Subject: Re: SPSS program: Confidence Interval for Cohen's d Based on the Noncentral t-Distribution‏
> To: [hidden email]
>
> Why not build some loops rather than going at it with a sledge hammer by
> building 2 million cases?
> Also get rid of the EXECUTE statements!
> --
>
> valferes wrote
> > Dear Rich Ulrich,I would be very grateful if you could show me your
> > solution to the same problem:
> >  
> > * My data: t observed and degrees of freedom.
> > data list list/tobs(f12.10) df(f8.0).
> > begin data.
> > 2.4592681838 33
> > end data.
> >
> > * Problem: Find the noncentrality parameters for p1=.025 and p2=.975.
> > My code is here and the illustrative output is here.
> > Sincerely,
> > Valentim R. Alferes
> > http://gaius.fpce.uc.pt/niips/ 
> >   Date: Tue, 29 Jul 2014 00:45:37 -0400
> > From:
>
> > rich-ulrich@
>
> > Subject: Re: SPSS program: Confidence Interval for Cohen's d Based on the
> > Noncentral t-Distribution‏
> > To:
>
> > SPSSX-L@.UGA
>
> >
> >
> >
> >  I needed an inverse, back in the days when computers were more finite, so
> > I found the other way.
> >
> > The other way to get the inverse from the cumulative distribution is to
> > interpolate (using transformed scales that produce approximate linearity)
> > and iterate.  Two iterations should give you the 4th decimal.
> >
> > --
> > Rich Ulrich
> >
> > Date: Mon, 28 Jul 2014 19:01:28 +0000
> > From:
>
> > valferes@
>
> > Subject: Re: SPSS program: Confidence Interval for Cohen's d Based on the
> > Noncentral t-Distribution‏
> > To:
>
> > SPSSX-L@.UGA
>
> >
> >
> >
> >  David,Given that SPSS has not the “Inverse Noncentral t Cumulative
> > Distribution Function”, there is only one way to obtain the accurate value
> > ​​of a noncentrality parameter (NCP) for a given probability: to use the
> > “Noncentral t Cumulative Distribution Function” and iteratively search for
> > the NCP. This is what the code does!The number of cases generated is a
> > simple matter of precision (with the current numbers, we obtain accurate
> > NCPs up to the fourth decimal place). The two “sort commands” are needed
> > because there are two NCP: for p = .025 and p = .975.I hope that SPSS 23
> > will include the “Inverse Noncentral t cdf”, as is the case of MATLAB (see
> > http://www.mathworks.com/help/stats/nctinv.html) ...=====================
> > To manage your subscription to SPSSX-L, send a message to
>
> > LISTSERV@.UGA
>
> >  (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    
> >
> > =====================
> > To manage your subscription to SPSSX-L, send a message to
>
> > LISTSERV@.UGA
>
> >  (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
>
>
>
>
>
> -----
> 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/SPSS-program-Confidence-Interval-for-Cohen-s-d-Based-on-the-Noncentral-t-Distribution-tp5726831p5726844.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
>
>
>
>
     

=====================
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
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: SPSS program: Confidence Interval for Cohen's d Based on the Noncentral t-Distribution‏

Bruce Weaver
Administrator
David, I'm getting the following error messages when I run that:

>Error # 4700 in column 7.  Text: minNCP
>An output command contains an unrecognized keyword.  The recognized keywords
>are OUTFILE, RECORDS, TABLE, and NOTABLE.
>Execution of this command stops.
 
>Error # 4702 in column 14.  Text: (
>An unexpected symbol was encountered on an output command.
 
>Error # 4700 in column 15.  Text: F10.6
>An output command contains an unrecognized keyword.  The recognized keywords
>are OUTFILE, RECORDS, TABLE, and NOTABLE.
 
>Error # 4702 in column 20.  Text: )
>An unexpected symbol was encountered on an output command.
   .39506810  4.48934000

Adding a slash to your first PRINT command fixes it.  I.e., changing this...

   PRINT minNCP (F10.6).

to this...

   PRINT /minNCP (F10.6).

With that change, I get the following error-free output:

NCPMacro d=0.84 N1=20 N2=15  .
   .395068
  4.489340
   .39506810  4.48934000


My version info:  v 21.0.0.2 for Windows, 64-bit, Windows 7 Professional, SP1.


David Marso wrote
40 seconds?
This runs in about 1/10th of a second and gives as much accuracy as could be desired!
-----
DEFINE NCPMacro (d !TOKENS(1) / N1 !TOKENS(1) /N2 !TOKENS(1) /CL !TOKENS(1) !DEFAULT (95) ).
INPUT PROGRAM.
LOOP #=1 TO 1.
END CASE.
END LOOP.
END FILE.
END INPUT PROGRAM.
COMPUTE CL=!CL.
COMPUTE df=!N1+!N2-2.
COMPUTE tobs=!d/sqr(1/!N1+1/!N2).
COMPUTE p1=1-((100-!CL)/100)/2.
SET MXLOOPS=100.
COMPUTE epsilon=.0000001.
VECTOR NCPs(2).
LOOP #=1 TO 2.
+  COMPUTE minabsdif=1.
+  COMPUTE bottomNCP=-10.
+  COMPUTE topNCP=10.
+  COMPUTE newdelta=1.
+  COMPUTE incr=1.
+  IF #=1 P=P1.
+  IF #=2 P=1-P1.
+  LOOP.
+    LOOP NCPvalue= bottomNCP TO topNCP BY incr.
+      COMPUTE delta=newdelta.
+      COMPUTE prob=ncdf.t(tobs,df,NCPvalue).
+      COMPUTE newdelta=abs(p-prob).
+      DO IF newdelta LT minabsdif.
+        COMPUTE minabsdif=newdelta.
+        COMPUTE minNCP=NCPvalue.
+      END IF.
+    END LOOP.
+    COMPUTE bottomNCP=minNCP-incr.
+    COMPUTE topNCP=minNCP+incr.
+    COMPUTE incr=incr/10.
+  END LOOP IF delta LE epsilon.
+  COMPUTE NCPs(#)=minNCP.
PRINT minNCP (F10.6).
END LOOP.
PRINT /NCPs1 NCPs2 (2F12.8).
EXECUTE.
!ENDDEFINE.
NCPMacro d=0.84 N1=20 N2=15  .

* result  .39506810  4.48934000

valferes wrote
David and Rich,

The code is entirely correct and provides reliable results (compare with ESCI
or MOTE outputs).
Moreover, it is done so that any novice user can get
the CI via a simplified input: d, N1
and N2.

The time it takes to run the syntax is negligible (on my computer, no more
than 40 seconds).




Anyway, I'm waiting for one of two solutions:

(a) Inverse Noncentral t cdf available in
IBM SPSS 23;

(b) The solution found
by Rich.

Sincerely,


Valentim


 
http://gaius.fpce.uc.pt/niips/ 


 

 
 
 
> Date: Tue, 29 Jul 2014 05:46:56 -0700
> From: [hidden email]
> Subject: Re: SPSS program: Confidence Interval for Cohen's d Based on the Noncentral t-Distribution‏
> To: [hidden email]
>
> Why not build some loops rather than going at it with a sledge hammer by
> building 2 million cases?
> Also get rid of the EXECUTE statements!
> --
>
> valferes wrote
> > Dear Rich Ulrich,I would be very grateful if you could show me your
> > solution to the same problem:
> >  
> > * My data: t observed and degrees of freedom.
> > data list list/tobs(f12.10) df(f8.0).
> > begin data.
> > 2.4592681838 33
> > end data.
> >
> > * Problem: Find the noncentrality parameters for p1=.025 and p2=.975.
> > My code is here and the illustrative output is here.
> > Sincerely,
> > Valentim R. Alferes
> > http://gaius.fpce.uc.pt/niips/ 
> >   Date: Tue, 29 Jul 2014 00:45:37 -0400
> > From:
>
> > rich-ulrich@
>
> > Subject: Re: SPSS program: Confidence Interval for Cohen's d Based on the
> > Noncentral t-Distribution‏
> > To:
>
> > SPSSX-L@.UGA
>
> >
> >
> >
> >  I needed an inverse, back in the days when computers were more finite, so
> > I found the other way.
> >
> > The other way to get the inverse from the cumulative distribution is to
> > interpolate (using transformed scales that produce approximate linearity)
> > and iterate.  Two iterations should give you the 4th decimal.
> >
> > --
> > Rich Ulrich
> >
> > Date: Mon, 28 Jul 2014 19:01:28 +0000
> > From:
>
> > valferes@
>
> > Subject: Re: SPSS program: Confidence Interval for Cohen's d Based on the
> > Noncentral t-Distribution‏
> > To:
>
> > SPSSX-L@.UGA
>
> >
> >
> >
> >  David,Given that SPSS has not the “Inverse Noncentral t Cumulative
> > Distribution Function”, there is only one way to obtain the accurate value
> > ​​of a noncentrality parameter (NCP) for a given probability: to use the
> > “Noncentral t Cumulative Distribution Function” and iteratively search for
> > the NCP. This is what the code does!The number of cases generated is a
> > simple matter of precision (with the current numbers, we obtain accurate
> > NCPs up to the fourth decimal place). The two “sort commands” are needed
> > because there are two NCP: for p = .025 and p = .975.I hope that SPSS 23
> > will include the “Inverse Noncentral t cdf”, as is the case of MATLAB (see
> > http://www.mathworks.com/help/stats/nctinv.html) ...=====================
> > To manage your subscription to SPSSX-L, send a message to
>
> > LISTSERV@.UGA
>
> >  (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    
> >
> > =====================
> > To manage your subscription to SPSSX-L, send a message to
>
> > LISTSERV@.UGA
>
> >  (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
>
>
>
>
>
> -----
> 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/SPSS-program-Confidence-Interval-for-Cohen-s-d-Based-on-the-Noncentral-t-Distribution-tp5726831p5726844.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
>
>
>
>
     

=====================
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
--
Bruce Weaver
bweaver@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

PLEASE NOTE THE FOLLOWING: 
1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above.
2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/).
Reply | Threaded
Open this post in threaded view
|

Re: SPSS program: Confidence Interval for Cohen's d Based on the Noncentral t-Distribution‏

David Marso
Administrator
I'd say get rid of that line altogether.
I'm not sure how I missed that (I must have accidently dislodged the / at one point).
Anyhow, it could probably be made a bit more efficient (no need probably to search the entire lo to hi range once one finds a minimum, but I got lazy).
--
Bruce Weaver wrote
David, I'm getting the following error messages when I run that:

>Error # 4700 in column 7.  Text: minNCP
>An output command contains an unrecognized keyword.  The recognized keywords
>are OUTFILE, RECORDS, TABLE, and NOTABLE.
>Execution of this command stops.
 
>Error # 4702 in column 14.  Text: (
>An unexpected symbol was encountered on an output command.
 
>Error # 4700 in column 15.  Text: F10.6
>An output command contains an unrecognized keyword.  The recognized keywords
>are OUTFILE, RECORDS, TABLE, and NOTABLE.
 
>Error # 4702 in column 20.  Text: )
>An unexpected symbol was encountered on an output command.
   .39506810  4.48934000

Adding a slash to your first PRINT command fixes it.  I.e., changing this...

   PRINT minNCP (F10.6).

to this...

   PRINT /minNCP (F10.6).

With that change, I get the following error-free output:

NCPMacro d=0.84 N1=20 N2=15  .
   .395068
  4.489340
   .39506810  4.48934000


My version info:  v 21.0.0.2 for Windows, 64-bit, Windows 7 Professional, SP1.


David Marso wrote
40 seconds?
This runs in about 1/10th of a second and gives as much accuracy as could be desired!
-----
DEFINE NCPMacro (d !TOKENS(1) / N1 !TOKENS(1) /N2 !TOKENS(1) /CL !TOKENS(1) !DEFAULT (95) ).
INPUT PROGRAM.
LOOP #=1 TO 1.
END CASE.
END LOOP.
END FILE.
END INPUT PROGRAM.
COMPUTE CL=!CL.
COMPUTE df=!N1+!N2-2.
COMPUTE tobs=!d/sqr(1/!N1+1/!N2).
COMPUTE p1=1-((100-!CL)/100)/2.
SET MXLOOPS=100.
COMPUTE epsilon=.0000001.
VECTOR NCPs(2).
LOOP #=1 TO 2.
+  COMPUTE minabsdif=1.
+  COMPUTE bottomNCP=-10.
+  COMPUTE topNCP=10.
+  COMPUTE newdelta=1.
+  COMPUTE incr=1.
+  IF #=1 P=P1.
+  IF #=2 P=1-P1.
+  LOOP.
+    LOOP NCPvalue= bottomNCP TO topNCP BY incr.
+      COMPUTE delta=newdelta.
+      COMPUTE prob=ncdf.t(tobs,df,NCPvalue).
+      COMPUTE newdelta=abs(p-prob).
+      DO IF newdelta LT minabsdif.
+        COMPUTE minabsdif=newdelta.
+        COMPUTE minNCP=NCPvalue.
+      END IF.
+    END LOOP.
+    COMPUTE bottomNCP=minNCP-incr.
+    COMPUTE topNCP=minNCP+incr.
+    COMPUTE incr=incr/10.
+  END LOOP IF delta LE epsilon.
+  COMPUTE NCPs(#)=minNCP.
PRINT minNCP (F10.6).
END LOOP.
PRINT /NCPs1 NCPs2 (2F12.8).
EXECUTE.
!ENDDEFINE.
NCPMacro d=0.84 N1=20 N2=15  .

* result  .39506810  4.48934000

valferes wrote
David and Rich,

The code is entirely correct and provides reliable results (compare with ESCI
or MOTE outputs).
Moreover, it is done so that any novice user can get
the CI via a simplified input: d, N1
and N2.

The time it takes to run the syntax is negligible (on my computer, no more
than 40 seconds).




Anyway, I'm waiting for one of two solutions:

(a) Inverse Noncentral t cdf available in
IBM SPSS 23;

(b) The solution found
by Rich.

Sincerely,


Valentim


 
http://gaius.fpce.uc.pt/niips/ 


 

 
 
 
> Date: Tue, 29 Jul 2014 05:46:56 -0700
> From: [hidden email]
> Subject: Re: SPSS program: Confidence Interval for Cohen's d Based on the Noncentral t-Distribution‏
> To: [hidden email]
>
> Why not build some loops rather than going at it with a sledge hammer by
> building 2 million cases?
> Also get rid of the EXECUTE statements!
> --
>
> valferes wrote
> > Dear Rich Ulrich,I would be very grateful if you could show me your
> > solution to the same problem:
> >  
> > * My data: t observed and degrees of freedom.
> > data list list/tobs(f12.10) df(f8.0).
> > begin data.
> > 2.4592681838 33
> > end data.
> >
> > * Problem: Find the noncentrality parameters for p1=.025 and p2=.975.
> > My code is here and the illustrative output is here.
> > Sincerely,
> > Valentim R. Alferes
> > http://gaius.fpce.uc.pt/niips/ 
> >   Date: Tue, 29 Jul 2014 00:45:37 -0400
> > From:
>
> > rich-ulrich@
>
> > Subject: Re: SPSS program: Confidence Interval for Cohen's d Based on the
> > Noncentral t-Distribution‏
> > To:
>
> > SPSSX-L@.UGA
>
> >
> >
> >
> >  I needed an inverse, back in the days when computers were more finite, so
> > I found the other way.
> >
> > The other way to get the inverse from the cumulative distribution is to
> > interpolate (using transformed scales that produce approximate linearity)
> > and iterate.  Two iterations should give you the 4th decimal.
> >
> > --
> > Rich Ulrich
> >
> > Date: Mon, 28 Jul 2014 19:01:28 +0000
> > From:
>
> > valferes@
>
> > Subject: Re: SPSS program: Confidence Interval for Cohen's d Based on the
> > Noncentral t-Distribution‏
> > To:
>
> > SPSSX-L@.UGA
>
> >
> >
> >
> >  David,Given that SPSS has not the “Inverse Noncentral t Cumulative
> > Distribution Function”, there is only one way to obtain the accurate value
> > ​​of a noncentrality parameter (NCP) for a given probability: to use the
> > “Noncentral t Cumulative Distribution Function” and iteratively search for
> > the NCP. This is what the code does!The number of cases generated is a
> > simple matter of precision (with the current numbers, we obtain accurate
> > NCPs up to the fourth decimal place). The two “sort commands” are needed
> > because there are two NCP: for p = .025 and p = .975.I hope that SPSS 23
> > will include the “Inverse Noncentral t cdf”, as is the case of MATLAB (see
> > http://www.mathworks.com/help/stats/nctinv.html) ...=====================
> > To manage your subscription to SPSSX-L, send a message to
>
> > LISTSERV@.UGA
>
> >  (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    
> >
> > =====================
> > To manage your subscription to SPSSX-L, send a message to
>
> > LISTSERV@.UGA
>
> >  (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
>
>
>
>
>
> -----
> 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/SPSS-program-Confidence-Interval-for-Cohen-s-d-Based-on-the-Noncentral-t-Distribution-tp5726831p5726844.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
>
>
>
>
     

=====================
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
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: SPSS program: Confidence Interval for Cohen's d Based on the Noncentral t-Distribution‏

valferes
David,

Thank you very much for your Macro. I also made some changes in Syntax and now it runs about 4 times faster:

http://gaius.fpce.uc.pt/niips/spss_prc/meta/esCIdNCT.sps

If I further reduce the range of the possible NCP values, the Syntax is even faster:

http://gaius.fpce.uc.pt/niips/spss_prc/meta/esCIdNCTalt.sps

My initial goal was to condense the calculations into three or four lines of code in order to insert them in a broader program that includes different measures of effect size. For this, I still have to wait for the inverse non-central t distribution in SPSS 23.

Sincerely,

Valentim

http://gaius.fpce.uc.pt/niips/

 

> Date: Tue, 29 Jul 2014 13:23:52 -0700

> From: [hidden email]
> Subject: Re: SPSS program: Confidence Interval for Cohen's d Based on the Noncentral t-Distribution‏
> To: [hidden email]
>
> I'd say get rid of that line altogether.
> I'm not sure how I missed that (I must have accidently dislodged the / at
> one point).
> Anyhow, it could probably be made a bit more efficient (no need probably to
> search the entire lo to hi range once one finds a minimum, but I got lazy).
> --
>
> Bruce Weaver wrote
> > David, I'm getting the following error messages when I run that:
> >
> >>Error # 4700 in column 7. Text: minNCP
> >>An output command contains an unrecognized keyword. The recognized
> keywords
> >>are OUTFILE, RECORDS, TABLE, and NOTABLE.
> >>Execution of this command stops.
> >
> >>Error # 4702 in column 14. Text: (
> >>An unexpected symbol was encountered on an output command.
> >
> >>Error # 4700 in column 15. Text: F10.6
> >>An output command contains an unrecognized keyword. The recognized
> keywords
> >>are OUTFILE, RECORDS, TABLE, and NOTABLE.
> >
> >>Error # 4702 in column 20. Text: )
> >>An unexpected symbol was encountered on an output command.
> > .39506810 4.48934000
> >
> > Adding a slash to your first PRINT command fixes it. I.e., changing
> > this...
> >
> > PRINT minNCP (F10.6).
> >
> > to this...
> >
> > PRINT /minNCP (F10.6).
> >
> > With that change, I get the following error-free output:
> >
> > NCPMacro d=0.84 N1=20 N2=15 .
> > .395068
> > 4.489340
> > .39506810 4.48934000
> >
> >
> > My version info: v 21.0.0.2 for Windows, 64-bit, Windows 7 Professional,
> > SP1.
> >
> > David Marso wrote
> >> 40 seconds?
> >> This runs in about 1/10th of a second and gives as much accuracy as could
> >> be desired!
> >> -----
> >> DEFINE NCPMacro (d !TOKENS(1) / N1 !TOKENS(1) /N2 !TOKENS(1) /CL
> >> !TOKENS(1) !DEFAULT (95) ).
> >> INPUT PROGRAM.
> >> LOOP #=1 TO 1.
> >> END CASE.
> >> END LOOP.
> >> END FILE.
> >> END INPUT PROGRAM.
> >> COMPUTE CL=!CL.
> >> COMPUTE df=!N1+!N2-2.
> >> COMPUTE tobs=!d/sqr(1/!N1+1/!N2).
> >> COMPUTE p1=1-((100-!CL)/100)/2.
> >> SET MXLOOPS=100.
> >> COMPUTE epsilon=.0000001.
> >> VECTOR NCPs(2).
> >> LOOP #=1 TO 2.
> >> + COMPUTE minabsdif=1.
> >> + COMPUTE bottomNCP=-10.
> >> + COMPUTE topNCP=10.
> >> + COMPUTE newdelta=1.
> >> + COMPUTE incr=1.
> >> + IF #=1 P=P1.
> >> + IF #=2 P=1-P1.
> >> + LOOP.
> >> + LOOP NCPvalue= bottomNCP TO topNCP BY incr.
> >> + COMPUTE delta=newdelta.
> >> + COMPUTE prob=ncdf.t(tobs,df,NCPvalue).
> >> + COMPUTE newdelta=abs(p-prob).
> >> + DO IF newdelta LT minabsdif.
> >> + COMPUTE minabsdif=newdelta.
> >> + COMPUTE minNCP=NCPvalue.
> >> + END IF.
> >> + END LOOP.
> >> + COMPUTE bottomNCP=minNCP-incr.
> >> + COMPUTE topNCP=minNCP+incr.
> >> + COMPUTE incr=incr/10.
> >> + END LOOP IF delta LE epsilon.
> >> + COMPUTE NCPs(#)=minNCP.
> >> PRINT minNCP (F10.6).
> >> END LOOP.
> >> PRINT /NCPs1 NCPs2 (2F12.8).
> >> EXECUTE.
> >> !ENDDEFINE.
> >> NCPMacro d=0.84 N1=20 N2=15 .
> >>
> >> * result .39506810 4.48934000
> >> valferes wrote
> >>> David and Rich,
> >>>
> >>> The code is entirely correct and provides reliable results (compare with
> >>> ESCI
> >>> or MOTE outputs).
> >>> Moreover, it is done so that any novice user can get
> >>> the CI via a simplified input: d, N1
> >>> and N2.
> >>>
> >>> The time it takes to run the syntax is negligible (on my computer, no
> >>> more
> >>> than 40 seconds).
> >>>
> >>>
> >>>
> >>>
> >>> Anyway, I'm waiting for one of two solutions:
> >>>
> >>> (a) Inverse Noncentral t cdf available in
> >>> IBM SPSS 23;
> >>>
> >>> (b) The solution found
> >>> by Rich.
> >>>
> >>> Sincerely,
> >>>
> >>>
> >>> Valentim
> >>>
> >>>
> >>>
> >>> http://gaius.fpce.uc.pt/niips/
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>> Date: Tue, 29 Jul 2014 05:46:56 -0700
> >>>> From:
>
> >>> david.marso@
>
> >>>> Subject: Re: SPSS program: Confidence Interval for Cohen's d Based on
> >>>> the Noncentral t-Distribution‏
> >>>> To:
>
> >>> SPSSX-L@.UGA
>
> >>>>
> >>>> Why not build some loops rather than going at it with a sledge hammer
> >>>> by
> >>>> building 2 million cases?
> >>>> Also get rid of the EXECUTE statements!
> >>>> --
> >>>>
> >>>> valferes wrote
> >>>> > Dear Rich Ulrich,I would be very grateful if you could show me your
> >>>> > solution to the same problem:
> >>>> >
> >>>> > * My data: t observed and degrees of freedom.
> >>>> > data list list/tobs(f12.10) df(f8.0).
> >>>> > begin data.
> >>>> > 2.4592681838 33
> >>>> > end data.
> >>>> >
> >>>> > * Problem: Find the noncentrality parameters for p1=.025 and p2=.975.
> >>>> > My code is here and the illustrative output is here.
> >>>> > Sincerely,
> >>>> > Valentim R. Alferes
> >>>> > http://gaius.fpce.uc.pt/niips/
> >>>> > Date: Tue, 29 Jul 2014 00:45:37 -0400
> >>>> > From:
> >>>>
> >>>> > rich-ulrich@
> >>>>
> >>>> > Subject: Re: SPSS program: Confidence Interval for Cohen's d Based on
> >>>> the
> >>>> > Noncentral t-Distribution‏
> >>>> > To:
> >>>>
> >>>> > SPSSX-L@.UGA
> >>>>
> >>>> >
> >>>> >
> >>>> >
> >>>> > I needed an inverse, back in the days when computers were more
> >>>> finite, so
> >>>> > I found the other way.
> >>>> >
> >>>> > The other way to get the inverse from the cumulative distribution is
> >>>> to
> >>>> > interpolate (using transformed scales that produce approximate
> >>>> linearity)
> >>>> > and iterate. Two iterations should give you the 4th decimal.
> >>>> >
> >>>> > --
> >>>> > Rich Ulrich
> >>>> >
> >>>> > Date: Mon, 28 Jul 2014 19:01:28 +0000
> >>>> > From:
> >>>>
> >>>> > valferes@
> >>>>
> >>>> > Subject: Re: SPSS program: Confidence Interval for Cohen's d Based on
> >>>> the
> >>>> > Noncentral t-Distribution‏
> >>>> > To:
> >>>>
> >>>> > SPSSX-L@.UGA
> >>>>
> >>>> >
> >>>> >
> >>>> >
> >>>> > David,Given that SPSS has not the “Inverse Noncentral t Cumulative
> >>>> > Distribution Function”, there is only one way to obtain the accurate
> >>>> value
> >>>> > ​​of a noncentrality parameter (NCP) for a given probability: to use
> >>>> the
> >>>> > “Noncentral t Cumulative Distribution Function” and iteratively
> >>>> search for
> >>>> > the NCP. This is what the code does!The number of cases generated is
> >>>> a
> >>>> > simple matter of precision (with the current numbers, we obtain
> >>>> accurate
> >>>> > NCPs up to the fourth decimal place). The two “sort commands” are
> >>>> needed
> >>>> > because there are two NCP: for p = .025 and p = .975.I hope that SPSS
> >>>> 23
> >>>> > will include the “Inverse Noncentral t cdf”, as is the case of MATLAB
> >>>> (see
> >>>> > http://www.mathworks.com/help/stats/nctinv.html)
> >>>> ...=====================
> >>>> > To manage your subscription to SPSSX-L, send a message to
> >>>>
> >>>> > LISTSERV@.UGA
> >>>>
> >>>> > (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
> >>>> >
> >>>> > =====================
> >>>> > To manage your subscription to SPSSX-L, send a message to
> >>>>
> >>>> > LISTSERV@.UGA
> >>>>
> >>>> > (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
> >>>>
> >>>>
> >>>>
> >>>>
> >>>>
> >>>> -----
> >>>> 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/SPSS-program-Confidence-Interval-for-Cohen-s-d-Based-on-the-Noncentral-t-Distribution-tp5726831p5726844.html
> >>>> Sent from the SPSSX Discussion mailing list archive at Nabble.com.
> >>>>
> >>>> =====================
> >>>> To manage your subscription to SPSSX-L, send a message to
> >>>>
>
> >>> LISTSERV@.UGA
>
> >>> (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
> >>>>
> >>>>
> >>>>
> >>>>
> >>>
> >>>
> >>> =====================
> >>> To manage your subscription to SPSSX-L, send a message to
>
> >>> LISTSERV@.UGA
>
> >>> (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
>
>
>
>
>
> -----
> 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/SPSS-program-Confidence-Interval-for-Cohen-s-d-Based-on-the-Noncentral-t-Distribution-tp5726831p5726851.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
>
>
>
>
===================== 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
Reply | Threaded
Open this post in threaded view
|

Re: SPSS program: Confidence Interval for Cohen's d Based on the Noncentral t-Distribution‏

David Marso
Administrator
"My initial goal was to condense the calculations into three or four lines of code in order to insert "
Er how about 2 lines:

INSERT filename.
NCPMacro d=....N1=....N2=....

valferes wrote
David,

Thank you very much for your Macro. I also made
some changes in Syntax
and now it runs about
4 times faster:


http://gaius.fpce.uc.pt/niips/spss_prc/meta/esCIdNCT.sps


If I further reduce the range of the possible NCP values, the Syntax is even faster:


http://gaius.fpce.uc.pt/niips/spss_prc/meta/esCIdNCTalt.sps 


My initial goal was to condense the
calculations into three or four lines of code in order to insert them in a broader program that
includes different measures
of effect size. For
this, I still have to wait for
the inverse non-central t distribution in SPSS 23.




Sincerely,


Valentim


http://gaius.fpce.uc.pt/niips/ 



 > Date: Tue, 29 Jul 2014 13:23:52 -0700
> From: [hidden email]
> Subject: Re: SPSS program: Confidence Interval for Cohen's d Based on the Noncentral t-Distribution‏
> To: [hidden email]
>
> I'd say get rid of that line altogether.
> I'm not sure how I missed that (I must have accidently dislodged the / at
> one point).
> Anyhow, it could probably be made a bit more efficient (no need probably to
> search the entire lo to hi range once one finds a minimum, but I got lazy).
> --
>
> Bruce Weaver wrote
> > David, I'm getting the following error messages when I run that:
> >
> >>Error # 4700 in column 7.  Text: minNCP
> >>An output command contains an unrecognized keyword.  The recognized
> keywords
> >>are OUTFILE, RECORDS, TABLE, and NOTABLE.
> >>Execution of this command stops.
> >  
> >>Error # 4702 in column 14.  Text: (
> >>An unexpected symbol was encountered on an output command.
> >  
> >>Error # 4700 in column 15.  Text: F10.6
> >>An output command contains an unrecognized keyword.  The recognized
> keywords
> >>are OUTFILE, RECORDS, TABLE, and NOTABLE.
> >  
> >>Error # 4702 in column 20.  Text: )
> >>An unexpected symbol was encountered on an output command.
> >    .39506810  4.48934000
> >
> > Adding a slash to your first PRINT command fixes it.  I.e., changing
> > this...
> >
> >    PRINT minNCP (F10.6).
> >
> > to this...
> >
> >    PRINT /minNCP (F10.6).
> >
> > With that change, I get the following error-free output:
> >
> > NCPMacro d=0.84 N1=20 N2=15  .
> >    .395068
> >   4.489340
> >    .39506810  4.48934000
> >
> >
> > My version info:  v 21.0.0.2 for Windows, 64-bit, Windows 7 Professional,
> > SP1.
> >
> > David Marso wrote
> >> 40 seconds?
> >> This runs in about 1/10th of a second and gives as much accuracy as could
> >> be desired!
> >> -----
> >> DEFINE NCPMacro (d !TOKENS(1) / N1 !TOKENS(1) /N2 !TOKENS(1) /CL
> >> !TOKENS(1) !DEFAULT (95) ).
> >> INPUT PROGRAM.
> >> LOOP #=1 TO 1.
> >> END CASE.
> >> END LOOP.
> >> END FILE.
> >> END INPUT PROGRAM.
> >> COMPUTE CL=!CL.
> >> COMPUTE df=!N1+!N2-2.
> >> COMPUTE tobs=!d/sqr(1/!N1+1/!N2).
> >> COMPUTE p1=1-((100-!CL)/100)/2.
> >> SET MXLOOPS=100.
> >> COMPUTE epsilon=.0000001.
> >> VECTOR NCPs(2).
> >> LOOP #=1 TO 2.
> >> +  COMPUTE minabsdif=1.
> >> +  COMPUTE bottomNCP=-10.
> >> +  COMPUTE topNCP=10.
> >> +  COMPUTE newdelta=1.
> >> +  COMPUTE incr=1.
> >> +  IF #=1 P=P1.
> >> +  IF #=2 P=1-P1.
> >> +  LOOP.
> >> +    LOOP NCPvalue= bottomNCP TO topNCP BY incr.
> >> +      COMPUTE delta=newdelta.
> >> +      COMPUTE prob=ncdf.t(tobs,df,NCPvalue).
> >> +      COMPUTE newdelta=abs(p-prob).
> >> +      DO IF newdelta LT minabsdif.
> >> +        COMPUTE minabsdif=newdelta.
> >> +        COMPUTE minNCP=NCPvalue.
> >> +      END IF.
> >> +    END LOOP.
> >> +    COMPUTE bottomNCP=minNCP-incr.
> >> +    COMPUTE topNCP=minNCP+incr.
> >> +    COMPUTE incr=incr/10.
> >> +  END LOOP IF delta LE epsilon.
> >> +  COMPUTE NCPs(#)=minNCP.
> >> PRINT minNCP (F10.6).
> >> END LOOP.
> >> PRINT /NCPs1 NCPs2 (2F12.8).
> >> EXECUTE.
> >> !ENDDEFINE.
> >> NCPMacro d=0.84 N1=20 N2=15  .
> >>
> >> * result  .39506810  4.48934000
> >> valferes wrote
> >>> David and Rich,
> >>>
> >>> The code is entirely correct and provides reliable results (compare with
> >>> ESCI
> >>> or MOTE outputs).
> >>> Moreover, it is done so that any novice user can get
> >>> the CI via a simplified input: d, N1
> >>> and N2.
> >>>
> >>> The time it takes to run the syntax is negligible (on my computer, no
> >>> more
> >>> than 40 seconds).
> >>>
> >>>
> >>>
> >>>
> >>> Anyway, I'm waiting for one of two solutions:
> >>>
> >>> (a) Inverse Noncentral t cdf available in
> >>> IBM SPSS 23;
> >>>
> >>> (b) The solution found
> >>> by Rich.
> >>>
> >>> Sincerely,
> >>>
> >>>
> >>> Valentim
> >>>
> >>>
> >>>  
> >>> http://gaius.fpce.uc.pt/niips/ 
> >>>
> >>>
> >>>  
> >>>
> >>>  
> >>>  
> >>>  
> >>>> Date: Tue, 29 Jul 2014 05:46:56 -0700
> >>>> From:
>
> >>> david.marso@
>
> >>>> Subject: Re: SPSS program: Confidence Interval for Cohen's d Based on
> >>>> the Noncentral t-Distribution‏
> >>>> To:
>
> >>> SPSSX-L@.UGA
>
> >>>>
> >>>> Why not build some loops rather than going at it with a sledge hammer
> >>>> by
> >>>> building 2 million cases?
> >>>> Also get rid of the EXECUTE statements!
> >>>> --
> >>>>
> >>>> valferes wrote
> >>>> > Dear Rich Ulrich,I would be very grateful if you could show me your
> >>>> > solution to the same problem:
> >>>> >  
> >>>> > * My data: t observed and degrees of freedom.
> >>>> > data list list/tobs(f12.10) df(f8.0).
> >>>> > begin data.
> >>>> > 2.4592681838 33
> >>>> > end data.
> >>>> >
> >>>> > * Problem: Find the noncentrality parameters for p1=.025 and p2=.975.
> >>>> > My code is here and the illustrative output is here.
> >>>> > Sincerely,
> >>>> > Valentim R. Alferes
> >>>> > http://gaius.fpce.uc.pt/niips/ 
> >>>> >   Date: Tue, 29 Jul 2014 00:45:37 -0400
> >>>> > From:
> >>>>
> >>>> > rich-ulrich@
> >>>>
> >>>> > Subject: Re: SPSS program: Confidence Interval for Cohen's d Based on
> >>>> the
> >>>> > Noncentral t-Distribution‏
> >>>> > To:
> >>>>
> >>>> > SPSSX-L@.UGA
> >>>>
> >>>> >
> >>>> >
> >>>> >
> >>>> >  I needed an inverse, back in the days when computers were more
> >>>> finite, so
> >>>> > I found the other way.
> >>>> >
> >>>> > The other way to get the inverse from the cumulative distribution is
> >>>> to
> >>>> > interpolate (using transformed scales that produce approximate
> >>>> linearity)
> >>>> > and iterate.  Two iterations should give you the 4th decimal.
> >>>> >
> >>>> > --
> >>>> > Rich Ulrich
> >>>> >
> >>>> > Date: Mon, 28 Jul 2014 19:01:28 +0000
> >>>> > From:
> >>>>
> >>>> > valferes@
> >>>>
> >>>> > Subject: Re: SPSS program: Confidence Interval for Cohen's d Based on
> >>>> the
> >>>> > Noncentral t-Distribution‏
> >>>> > To:
> >>>>
> >>>> > SPSSX-L@.UGA
> >>>>
> >>>> >
> >>>> >
> >>>> >
> >>>> >  David,Given that SPSS has not the “Inverse Noncentral t Cumulative
> >>>> > Distribution Function”, there is only one way to obtain the accurate
> >>>> value
> >>>> > ​​of a noncentrality parameter (NCP) for a given probability: to use
> >>>> the
> >>>> > “Noncentral t Cumulative Distribution Function” and iteratively
> >>>> search for
> >>>> > the NCP. This is what the code does!The number of cases generated is
> >>>> a
> >>>> > simple matter of precision (with the current numbers, we obtain
> >>>> accurate
> >>>> > NCPs up to the fourth decimal place). The two “sort commands” are
> >>>> needed
> >>>> > because there are two NCP: for p = .025 and p = .975.I hope that SPSS
> >>>> 23
> >>>> > will include the “Inverse Noncentral t cdf”, as is the case of MATLAB
> >>>> (see
> >>>> > http://www.mathworks.com/help/stats/nctinv.html)
> >>>> ...=====================
> >>>> > To manage your subscription to SPSSX-L, send a message to
> >>>>
> >>>> > LISTSERV@.UGA
> >>>>
> >>>> >  (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    
> >>>> >
> >>>> > =====================
> >>>> > To manage your subscription to SPSSX-L, send a message to
> >>>>
> >>>> > LISTSERV@.UGA
> >>>>
> >>>> >  (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
> >>>>
> >>>>
> >>>>
> >>>>
> >>>>
> >>>> -----
> >>>> 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/SPSS-program-Confidence-Interval-for-Cohen-s-d-Based-on-the-Noncentral-t-Distribution-tp5726831p5726844.html
> >>>> Sent from the SPSSX Discussion mailing list archive at Nabble.com.
> >>>>
> >>>> =====================
> >>>> To manage your subscription to SPSSX-L, send a message to
> >>>>
>
> >>> LISTSERV@.UGA
>
> >>>  (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
> >>>>
> >>>>
> >>>>
> >>>>
> >>>      
> >>>
> >>> =====================
> >>> To manage your subscription to SPSSX-L, send a message to
>
> >>> LISTSERV@.UGA
>
> >>>  (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
>
>
>
>
>
> -----
> 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/SPSS-program-Confidence-Interval-for-Cohen-s-d-Based-on-the-Noncentral-t-Distribution-tp5726831p5726851.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
>
>
>
>
     

=====================
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
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?"