# SPSS Syntax - Linear Interpolation

16 messages
Open this post in threaded view
|

## SPSS Syntax - Linear Interpolation

 This post was updated on . CONTENTS DELETED The author has deleted this message.
Open this post in threaded view
|

## SPSS Syntax - Equation of Line

 This post was updated on . CONTENTS DELETED The author has deleted this message.
Open this post in threaded view
|

## Re: SPSS Syntax - Linear Interpolation

 Administrator In reply to this post by JMA1234 Please provide a small example of what the data file looks like now, and what you want it to look like after.   AK1234 wrote I have 7 data points (time vs. melatonin concentration) for each ID number (in long format). I need to linear interpolate the time at two different set melatonin concentrations and then loop this through all ID numbers. If anyone has any suggestions on how I can do this, that would be greatly appreciated. -- Bruce Weaver bweaver@lakeheadu.ca http://sites.google.com/a/lakeheadu.ca/bweaver/"When all else fails, RTFM." NOTE: My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above.
Open this post in threaded view
|

## Re: SPSS Syntax - Linear Interpolation

 This post was updated on . CONTENTS DELETED The author has deleted this message.
Open this post in threaded view
|

## Re: SPSS Syntax - Linear Interpolation

In reply to this post by Bruce Weaver
I have to second Bruce's request because it hard to understand what
your data actually is.  You say you have long format data which
means you have 7 cases per ID but "time vs melatonin concentration"
make no sense.  Consider the following data layout for one ID:

 ID time mel_conc 001 1 202 001 2 222 001 3 241 001 4 269 001 5 280 001 6 299 001 7 320

Now this is all I can infer and I don't have much confidence that it
is completely correct (sorry, my ESP doesn't seem to be working today).
I assume that there is a positive linear relationship between mel_conc
and time which suggests that you can get a simple regression equation
to predict the value of mel_conc for any value of time (it is unclear
when you have actual times or ordered time points like above which
might be interpreted as the original time converted into ranks).

But I have to ask, why do you want to do linear interpolation?

My first inclination is that you have a melatonin concentration
for an ID but not the time, as follows:

 ID time mel_conc 001 3 241 001 269 001 5 280

Mel_conc=269 falls between the values of 241 and 280 and you
might want the time that corresponds to the missing time (if the
time is original time units and not ranks).  But you don't say
anything about missing data which implies you might be interested
in some time value between the times you (say, 3.5).  Again,
a simple regression equation would allow you to get this value
(run regression using split files using ID as the splitting variable)
but I still don't understand whether this is what you wnat to do
or why you might want to do it.

-Mike Palij
New York University

On Saturday, May 27, 2017 1:28 PM, Bruce Weaver wrote:
> Please provide a small example of what the data file looks like now, and what
> you want it to look like after.
>
> AK1234 wrote
>> I have 7 data points (time vs. melatonin concentration) for each ID number
>> (in long format). I need to linear interpolate the time at two different
>> set melatonin concentrations and then loop this through all ID numbers. If
>> anyone has any suggestions on how I can do this, that would be greatly
>> appreciated.
===================== 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
Open this post in threaded view
|

## Re: SPSS Syntax - Linear Interpolation

Open this post in threaded view
|

## Fw: SPSS Syntax - Linear Interpolation

In reply to this post by JMA1234
Note: the OP's posts are not making it to the mailing list
and I just checked Nabble to see the thread and I saw
that the OP has responded and uses a data layout much
like the one I use below.

After looking at you data table I think the question you
are asking is "what are the predicted times for melatonin
concentrations of 3 (units) and 4 (units)" which suggests
that you want to regression time in original units on
melatonin concentration [time = b_0 + b_1(mel_conc)].
Again, I think you may be able to this by using split files
and calculating the simple regression for each ID which
you can use to predict/calculate the time for mel_conc = 3 and 4.
The split files makes getting the regression equation simple
but then using them to calculate the melatonin concentration
is going to either require additional programming or hand
calculation.

A couple of notes:
(1)  People who are more familiar with multilevel analysis
can answer whether such an analysis would be appropriate
here in order to determine the regression of time on
melatonin is the same for all IDs or different across IDs.
If the regressions do not vary significant, then a single
equation could be used for all IDs.  If there is significant
difference among the equations (e.g. different slopes),
then you'll have to calculate the time on a ID level.

(2) A quick look at your data raises the question whether
melatonin actually has a linear relationship with time (or
vice versa).  Some IDs may have a quadratic relationship
or more complex pattern (theoretically, I believe, up to
6th order polynomial).

I'd like to see other people's suggestions.

-Mike Palij
New York University

----- Original Message -----
Sent: Saturday, May 27, 2017 2:02 PM
Subject: Re: SPSS Syntax - Linear Interpolation

I have to second Bruce's request because it hard to understand what
your data actually is.  You say you have long format data which
means you have 7 cases per ID but "time vs melatonin concentration"
make no sense.  Consider the following data layout for one ID:

 ID time mel_conc 001 1 202 001 2 222 001 3 241 001 4 269 001 5 280 001 6 299 001 7 320

Now this is all I can infer and I don't have much confidence that it
is completely correct (sorry, my ESP doesn't seem to be working today).
I assume that there is a positive linear relationship between mel_conc
and time which suggests that you can get a simple regression equation
to predict the value of mel_conc for any value of time (it is unclear
when you have actual times or ordered time points like above which
might be interpreted as the original time converted into ranks).

But I have to ask, why do you want to do linear interpolation?

My first inclination is that you have a melatonin concentration
for an ID but not the time, as follows:

 ID time mel_conc 001 3 241 001 269 001 5 280

Mel_conc=269 falls between the values of 241 and 280 and you
might want the time that corresponds to the missing time (if the
time is original time units and not ranks).  But you don't say
anything about missing data which implies you might be interested
in some time value between the times you (say, 3.5).  Again,
a simple regression equation would allow you to get this value
(run regression using split files using ID as the splitting variable)
but I still don't understand whether this is what you wnat to do
or why you might want to do it.

-Mike Palij
New York University

On Saturday, May 27, 2017 1:28 PM, Bruce Weaver wrote:
> Please provide a small example of what the data file looks like now, and what
> you want it to look like after.
>
> AK1234 wrote
>> I have 7 data points (time vs. melatonin concentration) for each ID number
>> (in long format). I need to linear interpolate the time at two different
>> set melatonin concentrations and then loop this through all ID numbers. If
>> anyone has any suggestions on how I can do this, that would be greatly
>> appreciated.
===================== 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
Open this post in threaded view
|

## Re: SPSS Syntax - Linear Interpolation

 This post was updated on . In reply to this post by Bruce Weaver CONTENTS DELETED The author has deleted this message.
Open this post in threaded view
|

## Re: SPSS Syntax - Linear Interpolation

 In looking at the two example cases, the relationship doesn't look too linear. That said, a linear assumption may be preferred. If so, that preference leads down one syntax path. Another syntax path is to interpolate the between points enclosing an interval that includes 3 or includes 4. These two different paths probably, almost certainly will give different time codes. Which way do you want to go? Gene Maguin -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of AK1234 Sent: Saturday, May 27, 2017 2:25 PM To: [hidden email] Subject: Re: SPSS Syntax - Linear Interpolation Hello Bruce, I should have clarified. MelaAvg corresponds with the melatonin concentration. I would like to linear interpolate the time at which a melatonin concentration of 3 and a melatonin of concentration of 4 are hit/surpassed. I have received confirmation that I was subscribed to the mailing list. I am unsure as to why it continues to say that my posts have not be accepted. I will look into this. Thank you for pointing that out. -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/SPSS-Syntax-Linear-Interpolation-tp5734282p5734290.htmlSent 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
Open this post in threaded view
|

## SPSS Syntax - Equation of the line

 This post was updated on . In reply to this post by JMA1234 CONTENTS DELETED The author has deleted this message.
Open this post in threaded view
|

## Re: SPSS Syntax - Equation of Line

 In reply to this post by JMA1234 CASESTOVARS is most likely part of the process. After doing CASESTOVARS for purposes of visualization before doing any analysis, I suggest you plot a line per person with concentration on the Y axis and "time" on the X axis.  You may want to break the data into sets of cases for the plots. Do the shapes appear at least vaguely similar? How do loess fits look? Is there reason to believe the shapes should be similar? Is there reason to believe the shape is linear? Are there subgroups of cases that you wish to compare/contrast their fit? For your two example cases, what value do you want the syntax to create? Art Kendall Social Research Consultants
Open this post in threaded view
|

## Re: SPSS Syntax - Equation of the line

 Administrator In reply to this post by JMA1234 JMA, no matter how urgent this may be for you, asking the same question repeatedly is not going to make anyone respond more quickly!  Bear in mind that it is the weekend, and a long weekend (Memorial Day) for our American friends.  So some potential respondents may not even see your question until Tuesday.   Note too that using different subject lines when asking the same question clutters up the archive unnecessarily.   JMA1234 wrote I am having trouble figuring out how to derive an equation of a line using SPSS syntax. More specifically, my data is in long format, with 7 data points (time vs. melatonin concentration) for each ID number. I would like to derive an equation for each individual based on their data points and then be able to compute predicted values for new points based on this equation. I hope that my question makes sense. Any assistance in this matter would be greatly appreciated. -- Bruce Weaver bweaver@lakeheadu.ca http://sites.google.com/a/lakeheadu.ca/bweaver/"When all else fails, RTFM." NOTE: My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above.
Open this post in threaded view
|

## Re: SPSS Syntax - Equation of Line

 This post was updated on . In reply to this post by Art Kendall CONTENTS DELETED The author has deleted this message.
Open this post in threaded view
|

## Re: SPSS Syntax - Equation of Line

 I think I would be confused a bit, even if I had read all the posts in sequence from Nabble. So, I confess that I'm not sure of the ultimate end. But if I wanted the regression for each person with 7 (always, exactly) points, 1 to 7, I would have all the 7 lines of data in one record and construct the simple linear contrast by hand, for (-3 to 3).   The covariance for the contrast term can be written like       3*(Mtime7- Mtime1) + 2*(Mtime6-Mtime2) + (Mtime5-Mtime3) and the sum of squares of the contrasts is 28.  Compute the mean and sum of squares of what I've labeled Mtime_   and you have all the values for the regression coefficient and the intercept.  -- Rich Ulrich From: SPSSX(r) Discussion <[hidden email]> on behalf of JMA1234 <[hidden email]> Sent: Sunday, May 28, 2017 9:22:53 AM To: [hidden email] Subject: Re: SPSS Syntax - Equation of Line   I would like to produce an equation for a line for each persons data based on their points. Essentially I would like to create a variable indicating the participant's slope of their line as well as another variable indicating the y-intercept of that line. -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/SPSS-Syntax-Linear-Interpolation-tp5734282p5734297.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