Math Homework

Ask Math Questions. Get Help With Your Math Homework

Ask an Expert,
Get an Answer ASAP!

This answer was rated:

This is an SPSS 14.0 question. I want to write a script

This is an SPSS 14.0...
This is an SPSS 14.0 question.

I want to write a script that will take X independent random samples from a data set, calculate the Pearson correlation for each sample, and write the values of r and p (only) to either an Excel or a Word file. I tried to do something with the LOOP command, but that only seems to work for data transformations. Any ideas?

R2
Show More
Show Less
Ask Your Own Math Homework Question
Customer reply replied 8 years ago
Relist: No answer yet.
If I don't hear anything in 24, I want a refund.

R2
Answered in 45 days by:
8/11/2010
mlamias
mlamias, Bachelor's Degree
Category: Math Homework
Satisfied Customers: 199
Experience: Bachelor's Degree in Statistics and Statistical Consultant to Federal Government Agencies and Business.
Verified
Hi, I have a question for you. What is the value of p supposed to be here? Also, I'm assuming r is the pearson correlation coefficient, but it's not clear what p is supposed to be.

Also, what size sample would you like to take? Will the sample size be constant accross all samples? For example, are you always sampling size 5 or size 12, etc?

Thanks.
Ask Your Own Math Homework Question
Hi,

Sorry it took so long for you to get a response. It looks like your question was filed under the "Computers" category, which I don't have access to since I'm only in the math category, so I'm just now seeing your post.

I have written SPSS Syntax in SPSS 17.0, which I believe should work just fine in your version of SPSS.

The code below needs a few modifications to run for you. You'll need to change the line:

GET FILE='F:\Program Files\SPSSInc\Statistics17\Samples\English\Employee data.sav'.

to point to the dataset that contains your data that you wish to sample from.

Then, you'll need to modify the SPSS macro call line:

correlation_simulation
samples=10
analvars=salary salbegin jobtime.

to be the number of samples you want to select, and you'll need to list the variable names you'd like to correlate.

Finally, you'll need to modify the line:

SELECT IF (Var2='Pearson Correlation' & Var1='salary').

by replacing the word salary with one of the variables you with to correlate with others. This will be your reference variable and will show a correlation of 1 (as its correlation with itself will always be 1).

The results will be stored in the Excel file: c:\Correlations.xls

HERE is the SPSS Syntax code:

***oms_bootstrapping.sps***.
***if c:\ is not a valid drive\path, replace all instances of c:\
with a valid drive\path.

PRESERVE.
SET TVARS NAMES.

*first OMS command just suppresses Viewer output.
OMS /DESTINATION VIEWER=NO /TAG='suppressall'.

*select correlation coefficients tables and write to data file.
oms select tables
/destination format = sav outfile = "C:\results2.sav"
/if commands = ['Correlations'] subtypes = ['Correlations']
/tag = "cor".

*define a macro to draw samples with replacement and
run Regression commands.
DEFINE correlation_simulation (samples=!TOKENS(1)
/analvars=!CMDEND)

COMPUTE dummyvar=1.
AGGREGATE
/OUTFILE='c:\aggrtemp.sav'
/BREAK=dummyvar
/filesize=N.
MATCH FILES FILE=* /TABLE='c:\aggrtemp.sav'
/BY dummyvar.
!DO !other=1 !TO !samples
SET SEED RANDOM.
WEIGHT OFF.
FILTER OFF.
DO IF $casenum=1.
- COMPUTE #samplesize=filesize.
- COMPUTE #filesize=filesize.
END IF.
DO IF (#samplesize>0 and #filesize>0).
- COMPUTE sampleWeight=rv.binom(#samplesize, 1/#filesize).
- COMPUTE #samplesize=#samplesize-sampleWeight.
- COMPUTE #filesize=#filesize-1.
ELSE.
- COMPUTE sampleWeight=0.
END IF.
WEIGHT BY sampleWeight.
FILTER BY sampleWeight.

correlations
/variables = !analvars .

!DOEND


!ENDDEFINE.

***insert any valid path\data file name***.
GET FILE='F:\Program Files\SPSSInc\Statistics17\Samples\English\Employee data.sav'.

***Call the macro, and specify number of samples,
dependent variable, and independent variables.
correlation_simulation
samples=100
analvars=salary salbegin jobtime.

OMSEND.


GET FILE 'c:\results2.sav'.

RESTORE .

USE ALL.
SELECT IF (Var2='Pearson Correlation' & Var1='salary').
EXECUTE .

***insert any valid path\data file name for the Excel File***.
SAVE TRANSLATE OUTFILE='C:\Correlations.xls'
/TYPE=xls
/FIELDNAMES
/CELLS=VALUES
/DROP=Command_ Subtype_ Label_ Var1
/REPLACE .

EXECUTE.







Ask Your Own Math Homework Question
Customer reply replied 8 years ago

p is the significance of the calculated correlation. It's standard SPSS output.

I'm looking for an Exel output file with three variables: the number of the sample (1 through S, where S is the requested number of samples), the correlation (r) obtained for each sample, and the associated value of p for each sample.

Can you do that? It's worth some extra $$ --

Thanks for all you've done so far.

Best regards,

R2

OK. I see what you are after. You are looking to have print out the sample number S, so if you simulated 100 samples of say, size n=10 you'd have S1-S100 as a variable, a p-value as another variable, and the pearson correlation coefficient as the third, right?

Can I assume that you will only be correlating two different variables in your dataset e.g. y and x?

Thanks.
Ask Your Own Math Homework Question
OK. I have a program that should work for now, I believe.

I implemented this as an SPSS macro, so you'll need to change a few parameters to make it run. These are:

1.The line that reads:

GET FILE='F:\Program Files\SPSSInc\Statistics17\Samples\English\Employee data.sav'.

Should be changed to point to the location of the file containing your data.

2. Change the parameters of the macro call below to match your needs.
samples=the number of simulations that you want to run. This will be equal to the number of rows in your Excel spreadsheet when the simulation completes.
var1=the first variable name that you want to correlate with var2.
var2=the second variable name that you want to correlate with var1.
N=The total number of observations in your file listed in step 1.
samplesize=the number of observations you want to randomly choose from your data for correlation

***Call the macro, and specify number of samples,
dependent variable, and independent variables.
correlation_simulation
samples=10
var1=prevexp var2=salbegin N=474 samplesize=50.

Good luck!

If you are satisfied with this solution, please click accept. Tips are always apprecaited!

--Tyler

Here's the syntax:

***oms_bootstrapping.sps***.
***if c:\ is not a valid drive\path, replace all instances of c:\
with a valid drive\path.

PRESERVE.
SET TVARS NAMES.

*first OMS command just suppresses Viewer output.
OMS /DESTINATION VIEWER=NO /TAG='suppressall'.

*select correlation coefficients tables and write to data file.
oms select tables
/destination format = sav outfile = "C:\results2.sav"
/if commands = ['Correlations'] subtypes = ['Correlations']
/tag = "cor".

*define a macro to draw samples with replacement and
run Regression commands.
DEFINE correlation_simulation (samples=!TOKENS(1)
/var1=!TOKENS(1)
/var2=!TOKENS(1)
/N=!TOKENS(1)
/samplesize=!TOKENS(1))

!DO !other=1 !TO !samples
SET SEED RANDOM.
USE ALL.
do if $casenum=1.
compute #s_$_1= !samplesize .
compute #s_$_2= !N .
end if.
do if #s_$_2 > 0.
compute filter_$=uniform(1)* #s_$_2 < #s_$_1.
compute #s_$_1=#s_$_1 - filter_$.
compute #s_$_2=#s_$_2 - 1.
else.
compute filter_$=0.
end if.
VARIABLE LABEL filter_$ 'samplesize from the first N cases (SAMPLE)'.
FORMAT filter_$ (f1.0).
FILTER BY filter_$.
EXECUTE.

correlations
/variables = !var1 !var2 .

!DOEND
OMSEND.

GET FILE 'c:\results2.sav'.
SELECT IF (Var1=!QUOTE(!var1) & Var2<>'N').
compute S=$CASENUM.
IF (MOD($Casenum, 2) = 0) S = S-1.
EXECUTE.
RESTORE .
SAVE OUTFILE='c:\results3.sav'
/DROP=Command_ Subtype_ Label_ !Var1 Var1.
EXECUTE.

GET FILE 'c:\results3.sav'.
SELECT IF(Var2='Pearson Correlation').
compute r=salbegin.
EXECUTE.
SAVE OUTFILE='c:\r.sav'
/DROP=Var2 !var2.
EXECUTE.

GET FILE 'c:\results3.sav'.
SELECT IF(Var2='Sig. (2-tailed)').
compute p=salbegin.
EXECUTE.
SAVE OUTFILE='c:\p.sav'
/DROP=Var2 !var2.
EXECUTE.

GET FILE 'c:\r.sav'.
MATCH FILES /FILE=*
/FILE='c:\p.sav'
/BY S.
EXECUTE.
COMPUTE S=$CASENUM.
EXECUTE.

***insert any valid path\data file name for the Excel File***.
SAVE TRANSLATE OUTFILE='C:\Correlations.xls'
/TYPE=xls
/FIELDNAMES
/CELLS=VALUES
/REPLACE .

EXECUTE.

!ENDDEFINE.

***insert any valid path\data file name***.
GET FILE='F:\Program Files\SPSSInc\Statistics17\Samples\English\Employee data.sav'.

***Call the macro, and specify number of samples,
dependent variable, and independent variables.
correlation_simulation
samples=10
var1=prevexp var2=salbegin N=474 samplesize=50.
mlamias
mlamias, Bachelor's Degree
Category: Math Homework
Satisfied Customers: 199
Experience: Bachelor's Degree in Statistics and Statistical Consultant to Federal Government Agencies and Business.
Verified
mlamias and 87 other Math Homework Specialists are ready to help you
Ask your own question now
Customer reply replied 8 years ago

That's right, only two variables.

This is a teaching app. I'll compute a data set consisting of X and Y, in which X and Y are randomly generated, separately generated, and therefore guaranteed to be uncorrelated. After using the app to take a hundred samples and calculate r and p, the students can see that roughly five of the correlations are significant, despite the fact that X and Y are KNOWN to be uncorrelated. This will demonstrate that p is, in fact, the probability of getting a particular sample correlation if the null hypothesis is true in the population.

In any event, that's probably more info than you need. Does your answer require any tweaking, or are we done? BTW: If you'd like to keep a copy for your own teaching, or resale, be my guest.

R2

Ahhh! What a great teaching app! It will be very nice for student to be able to use this.

Then, yes, we should be all done and the app should be ready to use, after you change the variables as indicated.

Thanks again for allowing me to keep a copy of the code.

If you find my response acceptable, please click accept.

--Tyler
Ask Your Own Math Homework Question
Customer reply replied 8 years ago

It's been a pleasure. If I have another problem in this area, I'll ask for you by name.

 

Best regards

Roger B. Rensvold, PhD

TUI University

Fantastic! That sounds great. I look forward to working with you again in the future. Take care.

--Tyler
Ask Your Own Math Homework Question
Was this answer helpful?

How JustAnswer works

step-image
Describe your issueThe assistant will guide you
step-image
Chat 1:1 with a math tutor or teacherLicensed Experts are available 24/7
step-image
100% satisfaction guaranteeGet all the answers you need
Ask mlamias Your Own Question
mlamias
mlamias
mlamias, Bachelor's Degree
Category: Math Homework
Satisfied Customers: 199
199 Satisfied Customers
Experience: Bachelor's Degree in Statistics and Statistical Consultant to Federal Government Agencies and Business.

mlamias is online now

A new question is answered every 9 seconds

How JustAnswer works:

  • Ask an ExpertExperts are full of valuable knowledge and are ready to help with any question. Credentials confirmed by a Fortune 500 verification firm.
  • Get a Professional AnswerVia email, text message, or notification as you wait on our site. Ask follow up questions if you need to.
  • 100% Satisfaction GuaranteeRate the answer you receive.

JustAnswer in the News:

Ask-a-doc Web sites: If you've got a quick question, you can try to get an answer from sites that say they have various specialists on hand to give quick answers... Justanswer.com.
JustAnswer.com...has seen a spike since October in legal questions from readers about layoffs, unemployment and severance.
Web sites like justanswer.com/legal
...leave nothing to chance.
Traffic on JustAnswer rose 14 percent...and had nearly 400,000 page views in 30 days...inquiries related to stress, high blood pressure, drinking and heart pain jumped 33 percent.
Tory Johnson, GMA Workplace Contributor, discusses work-from-home jobs, such as JustAnswer in which verified Experts answer people’s questions.
I will tell you that...the things you have to go through to be an Expert are quite rigorous.

What Customers are Saying:

Wonderful service, prompt, efficient, and accurate. Couldn't have asked for more. I cannot thank you enough for your help.

Mary C.Freshfield, Liverpool, UK

This expert is wonderful. They truly know what they are talking about, and they actually care about you. They really helped put my nerves at ease. Thank you so much!!!!

AlexLos Angeles, CA

Thank you for all your help. It is nice to know that this service is here for people like myself, who need answers fast and are not sure who to consult.

GPHesperia, CA

I couldn't be more satisfied! This is the site I will always come to when I need a second opinion.

JustinKernersville, NC

Just let me say that this encounter has been entirely professional and most helpful. I liked that I could ask additional questions and get answered in a very short turn around.

EstherWoodstock, NY

Thank you so much for taking your time and knowledge to support my concerns. Not only did you answer my questions, you even took it a step further with replying with more pertinent information I needed to know.

RobinElkton, Maryland

He answered my question promptly and gave me accurate, detailed information. If all of your experts are half as good, you have a great thing going here.

DianeDallas, TX

< Previous | Next >

Meet the Experts:

Mr. Gregory White

Mr. Gregory White

Master's Degree

92 satisfied customers

M.A., M.S. Education / Educational Administration

JACUSTOMER-yrynbdjl-

JACUSTOMER-yrynbdjl-

Master's Degree

49 satisfied customers

I have taught college Mathematics for the past 10 years.

SusanAthena

SusanAthena

Master's Degree

41 satisfied customers

Tutor for Algebra, Geometry, Statistics. Explaining math in plain English.

Dr Arthur Rubin

Dr Arthur Rubin

Doctoral Degree

38 satisfied customers

Ph.D. in Mathematics, California Institute of Technology

mhasan420

mhasan420

Master's Degree

29 satisfied customers

BA Maths, Oxford

Don

Don

Master's Degree

17 satisfied customers

M.S. Astronautical Engineering. Math/Science/Comp Tutor

judybailey61

judybailey61

Bachelor's Degree

17 satisfied customers

20 years teaching mathematics

< Previous | Next >

Related Math Homework Questions
I am suppose to analyze variables in a data set and gpa. I
I am suppose to analyze variables in a data set for gender and gpa. I am suppose to provide a context of theis data set including a definition of the variables(predictor, outcome) and corresponding sc… read more
GLENN GILONGOS
GLENN GILONGOS
Master of Mathematics
420 satisfied customers
this Math assignment involves probability and carlo simulation
this Math assignment involves probability and monte carlo simulation using matlab programming language.… read more
Mr. Gregory White
Mr. Gregory White
Master's Degree
Master's Degree
92 satisfied customers
1. If your calculated r = -1.17, what does that indicate? 2.
1. If your calculated r = -1.17, what does that indicate? 2. Which shows a stronger relationship, a correlation coefficient of r = -.90 or r = + .30? 3. In a a two tailed test, with alpha set at .05, … read more
rajeevanpillai
rajeevanpillai
Master\u0027s Degree
22 satisfied customers
Using Matlab I need to create two vectors, x and y, with random
Using Matlab I need to create two vectors, x and y, with random values from [0,1] this I understand. Using Matlab's delaunay function a triangular mesh is then created. How is a function written using… read more
Fermat
Fermat
Master's Degree
17 satisfied customers
Construct the indicated confidence interval for the difference
Construct the indicated confidence interval for the difference population proportions. Assume that the samples are independent and that they have been randomly select. In a random sample of 300 women,… read more
Chirag
Chirag
Master\u0027s Degree
55 satisfied customers
FOR STEVE-STATISTICS 1. Suppose that a researcher wishes to
FOR STEVE-STATISTICS 1. Suppose that a researcher wishes to determine whether there is a linear relationship between weight and blood pressure in a sample of older persons in the community. Which stat… read more
Stevewh
Stevewh
Teacher
Bachelor's Degree
612 satisfied customers
Ryan, can you explain this for me. The teacher is making us
Ryan, can you explain this for me. The teacher is making us write a paper with variables that we picked but I don't understand what she wants can you help? 7) Identify and interpret the adjusted R2 (o… read more
Ryan
Ryan
Bachelor\u0027s Degree
1,060 satisfied customers
I am unsure as to how to use my data in order to conduct some
I am trying to analyse my data using a program called SPSS. Because my data is so variable however, I am unsure as to how to go about such an analysis. The project aim is to investigate what different… read more
R.R. Jha
R.R. Jha
Bachelor\u0027s Degree
150 satisfied customers
2. A set of n 5 pairs of X and Y values has X 10, Y 20,
2. A set of n = 5 pairs of X and Y values has X = 10, Y = 20, and XY = 60. For this set of scores, the value of SP is __________. A) –20 B) –28 C) 20 D) 60 3. A set of n = 5 pairs of X and Y values ha… read more
rajeevanpillai
rajeevanpillai
Master\u0027s Degree
22 satisfied customers
Problem 1 Complete Exercise 14.1 items (a) through (e) found
Problem 1: Complete Exercise 14.1 items (a) through (e) found on page 308 of the textbook. Problem 2: Download the data set na-bp.sav and use it to complete the following calculations in SPSS: (1) Pro… read more
R.R. Jha
R.R. Jha
Bachelor\u0027s Degree
150 satisfied customers
****THIS IS FOR Sk1llz************** I need help with three
****THIS IS FOR Sk1llz************** I need help with three questions Clearly define the regression (correlation) variables that you plan to investigate: More specifically, what are your independent a… read more
Sk1llz
Sk1llz
Math student
1,518 satisfied customers
Actually I have collected 389 random MRSA (bacterial samples)
Actually I have collected 389 random MRSA (bacterial samples) from infected patients within one year from hospital to do molecular epidemiology work. According to questionare were filled up during the… read more
Greg
Greg
Master\u0027s Degree
1,292 satisfied customers
1.) A regional commuter airline selected a random sample of
1.) A regional commuter airline selected a random sample of 25 flights and found that the correlation between the number of passengers and the total weight, in pounds, of luggage stored in the luggage… read more
muvee
muvee
Master's Degree
1,030 satisfied customers
Using Excel as your processing tool, work through three simple
Using Excel as your processing tool, work through three simple regression analyses. 1. First run a regression analysis using the BENEFITS column of all data points in the AIU data set as the independe… read more
Chirag
Chirag
Master\u0027s Degree
55 satisfied customers
Using Excel as your processing tool, work through three simple
Using Excel as your processing tool, work through three simple regression analyses. 1. First run a regression analysis using the BENEFITS column of all data points in the AIU data set as the independe… read more
Chirag
Chirag
Master\u0027s Degree
55 satisfied customers
Mary Sue wants to know if there is a connection between attendance
Mary Sue wants to know if there is a connection between attendance at craft fairs and the number of exhibitors who have booths at the fair. For a random sample of seven local craft fairs, she chose a … read more
Chirag
Chirag
Master\u0027s Degree
55 satisfied customers
Mary Sue wants to know if there is a connection between attendance
Mary Sue wants to know if there is a connection between attendance at craft fairs and the number of exhibitors who have booths at the fair. For a random sample of seven local craft fairs, she chose a … read more
SusanAthena
SusanAthena
Master's Degree
Master's Degree
41 satisfied customers
Directions read the following research problem and review
Directions: read the following research problem and review the two tables and then interpret the results. A group of nurse researchers measured the amount of time (in minutes) spent in recreational ac… read more
Sk1llz
Sk1llz
Math student
1,518 satisfied customers
Disclaimer: Information in questions, answers, and other posts on this site ("Posts") comes from individual users, not JustAnswer; JustAnswer is not responsible for Posts. Posts are for general information, are not intended to substitute for informed professional advice (medical, legal, veterinary, financial, etc.), or to establish a professional-client relationship. The site and services are provided "as is" with no warranty or representations by JustAnswer regarding the qualifications of Experts. To see what credentials have been verified by a third-party service, please click on the "Verified" symbol in some Experts' profiles. JustAnswer is not intended or designed for EMERGENCY questions which should be directed immediately by telephone or in-person to qualified professionals.

Disclaimer: Information in questions, answers, and other posts on this site ("Posts") comes from individual users, not JustAnswer; JustAnswer is not responsible for Posts. Posts are for general information, are not intended to substitute for informed professional advice (medical, legal, veterinary, financial, etc.), or to establish a professional-client relationship. The site and services are provided "as is" with no warranty or representations by JustAnswer regarding the qualifications of Experts. To see what credentials have been verified by a third-party service, please click on the "Verified" symbol in some Experts' profiles. JustAnswer is not intended or designed for EMERGENCY questions which should be directed immediately by telephone or in-person to qualified professionals.

Show MoreShow Less

Ask Your Question

x