How to write this in R Studio Let\'s consider there are 2 columns: n = \"number
ID: 3375735 • Letter: H
Question
How to write this in R Studio
Let's consider there are 2 columns: n = "number of days till failure occurs"
T = "mean operating temperature"
df = Data Frame
Now, Correlation in R is given as:
cor(x, y, method = c("pearson", "kendall", "spearman"))
Generally we use "pearson correlation" and it is set by default so below command will work fine.
cor(df$T, df$n)
This will print value of correlation between 2 columns.
Use randomisation to test at a significance level of 5%
whether there is evidence that a higher mean operating temperature is associated to earlier failure.
(the R code for "randomisation to test at a significance level of 5%" )
Explanation / Answer
To find the evidence that a higher mean operating temperature is associated to earlier failure we will perform regression model with mean operating temperature as dependent variable and number of days till failure occurs as an independent variable.
If the higher mean operating temperature is associated to earlier failure then the correlation between variables T and n should be negative because as temperature increases the number of days till failure occurs decreases.
The R code will be:
Model<-lm(df$T,df$n)
summary(Model)
When the summary will be printed, you will see P-values corresponding to constant and n. If the p-value corresponding to n is less than the level of significance 0.05 then we will conclude that there is evidence that a higher mean operating temperature is associated to earlier failure.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.