Lab Checkup Notes 2 - Google Docs
Lab Checkup Notes 2 - Google Docs
Lab 5: R Skills
● How to execute a command
○ Highlight it and push control enter ( it should pop up in r console) example: v1
<- c(1,2,3,4,5)
■ This creates a vector in R’s memory
○ You can then “call” this vector by typing “v1” and click enter
■ This is a new “object”
○ Type “objects()” and click enter and you will see a list of vectors you have
creator ex: v1 and v2
● Using “scan” function
○ Type: v3 <- scan() and push enter
○ A number 1 with a colon will appear, input numbers for 1-10 and push enter
twice when you get to 11
○ Now when you call “v3” these 10 numbers will appear
● Histogram
○ Type “hist(v4)”
○ Should appear in “plots” on the right side
Errors:
Types of tests:
■
Change 1 to -1 : pnorm(-1, mean = 0, sd = 1)
To calculate the probability
between two scores
: Subtract
the smaller cumulative probability from the larger
■
pnorm(1, mean = 0, sd = 1) - pnorm(-1, mean = 0, sd =
1)
●
Calculate confidence interval for a mean
Use the
scan()
function to input values one by one.
Press
[Enter]
after each score, and
[Enter]
twice to finish.
■
Example input:
12, 20, 34, 45, 34, 36, 37, 50, 11, 32,
29
.
○
Print data to verify
■
my_data
○
Find how many scores in my data set
■
length(my_data)
○
Calculate the 95% confidence interval around the mean
■
Use t.test function
■
t.test(my_data, conf.level = 0.95)
●
Perform a one sample t test
○
Replace
mu
with the hypothesized mean:
■
Code: t.test(my_data, mu = hypothesized_mean)
Look at the
p-value
:
●
If
p < 0.05
: Reject the null hypothesis (significant difference).
●
If
p ≥ 0.05
: Fail to reject the null hypothesis (no significant
difference).
Study Guide:
Compute Variable:
● Go toTransform>Compute Variable.
PROBAB
● InTarget Variable, type .
Select Function:
Set Parameters:
?with
● Replace the first IQ
.
?with
● Replace the second 100(mean).
?with
● Replace the third 15(standard deviation).
Confirm Syntax:
CDF.NORMAL(IQ,100,15)
● Ensure it reads .
● ClickOK.
Prepare Data:
● Ensure your dependent variable (e.g., scores) is in one column, and your grouping
variable (e.g., group labels) is in another.
● Go to Analyze > Compare Means > Independent Samples T-Test.
Assign Variables:
Define Groups:
● Click Define Groups, input the codes for each group (e.g., 1 for Group 1, 2 for Group
2), and click Continue.
Run Test:
● Click Paste to generate syntax (optional), then execute the test.
Review Output:
● Check Levene's Test to assess equal variances (Sig. > 0.05 means variances are
equal).
● Interpret the t-test results for t-value, df, and p-value (Sig. 2-tailed).
Open Data:
● Ensure two related variables (e.g., scores for two conditions) are in two separate
columns, with rows representing individual participants.
● Go to Analyze > Compare Means > Paired Samples T-Test.
Select Variables:
● Assign one column to Variable 1 and the other column to Variable 2.
Run Test:
● Click Paste to generate syntax (optional), then execute the test.
Interpret Output:
Create Variables:
Enter Data:
● Click on Post Hoc, select Tukey for equal variances or Games-Howell for unequal
variances.
● Click Continue.
Run Analysis:
● Click OK to execute.
Interpret Results:
● Check the ANOVA table in the output for the F-value and p-value.
● If significant, use post hoc tests to identify specific group differences.