Statystyka/testowe/.Rhistory
Jakub Adamski 91a91b1839 lab1-3
2021-06-17 15:50:43 +02:00

139 lines
5.7 KiB
R

computers <- read.table("http://pp98647.home.amu.edu.pl/wp-content/uploads/2021/06/computers.csv")
View(computers)
computers <- read.csv("http://pp98647.home.amu.edu.pl/wp-content/uploads/2021/06/computers.csv")
View(computers)
spotify <- read.csv("http://pp98647.home.amu.edu.pl/wp-content/uploads/2021/06/spotify.csv")
View(spotify)
weight_height <- read.csv("http://pp98647.home.amu.edu.pl/wp-content/uploads/2021/06/weight-height.csv")
View(weight_height)
model_1 <- lm(valence ~ acusticness + danceability + energy + instrumentalness +
liveness, data = spotify)
model_1 <- lm(valence ~ acousticness + danceability + energy + instrumentalness +
liveness, data = spotify)
model_1 <- lm(valence ~ acousticness + danceability + energy + instrumentalness +
liveness + loudness + speechiness + tempo + song_title, data = spotify)
model_1
summary(model_1)
model_1 <- lm(valence ~ acousticness + danceability + energy + instrumentalness +
liveness + loudness + speechiness + tempo, data = spotify)
summary(model_1)
step(model_1)
step(model_1)
step(model_1)
summary(model_1)
model_2 <- lm(valence ~ acousticness + danceability + energy + instrumentalness +
liveness + loudness + speechiness, data = spotify)
new_data <- data.frame(acousticness=2.84e-06, danceability=0.305, energy=0.827,
instrumentalness=2.45e-03, liveness=0.3350, loudness=-5.789, speechiness=0.1470)
View(new_data)
stats::predict(model_2, new_data, interval = "prediction")
summary(model_2)$adj.r.squared
new_data <- data.frame(acousticness=2.84e-06, danceability=0.305, energy=0.827,
instrumentalness=2.45e-03, liveness=0.3350, loudness=-5.789,
speechiness=0.1470, tempo=159.882)
stats::predict(model_2, new_data, interval = "prediction")
new_data <- data.frame(acousticness=2.84e-06, danceability=1.305, energy=0.827,
instrumentalness=2.45e-03, liveness=0.3350, loudness=-5.789,
speechiness=0.1470, tempo=159.882)
stats::predict(model_2, new_data, interval = "prediction")
new_data <- data.frame(acousticness=2.84e-06, danceability=0.305, energy=0.827,
instrumentalness=2.45e-03, liveness=0.3350, loudness=-5.789,
speechiness=0.1470, tempo=159.882)
stats::predict(model_2, new_data, interval = "prediction")
new_data <- data.frame(acousticness=2.84e-06, danceability=0.405, energy=0.827,
instrumentalness=2.45e-03, liveness=0.3350, loudness=-5.789,
speechiness=0.1470, tempo=159.882)
stats::predict(model_2, new_data, interval = "prediction")
new_data <- data.frame(acousticness=2.84e-06, danceability=0.305, energy=0.827,
instrumentalness=2.45e-03, liveness=0.3350, loudness=-5.789,
speechiness=0.1470, tempo=159.882)
stats::predict(model_2, new_data, interval = "prediction")
new_data <- data.frame(acousticness=2.84e-06, danceability=0.405, energy=0.827,
instrumentalness=2.45e-03, liveness=0.3350, loudness=-5.789,
speechiness=0.1470, tempo=159.882)
stats::predict(model_2, new_data, interval = "prediction")
0.3918359 - 0.3918359
0.3918359 - 0.3229826
male <- ifelse(weight_height$Gender == "Male")
male <- weight_height$Gender == "Male"
male <- ifelse(weight_height$Gender == "Male", weight_height$Height)
male <- ifelse(weight_height$Gender == "Male", weight_height$Height, 0)
male <- weight_height[weight_height$Gender == "Male"]
male <- weight_height[weight_height$Gender == "Male", ]
View(male)
shapiro.test(male$Height)
qqnorm(male$Height)
shapiro.test(male$Weight)
qqnorm(male$Weight)
shapiro.test(male$Height)
qqnorm(male$Height)
mean(male$Height)
par(mfrow = c(1, 2))
female <- weight_height[weight_height$Gender == "Female", ]
shapiro.test(female$Height)
qqnorm(female$Height)
mean(female$Height)
par(mfrow = c(1, 2))
male <- weight_height[weight_height$Gender == "Male", ]
shapiro.test(male$Height)
qqnorm(male$Height)
mean(male$Height)
female <- weight_height[weight_height$Gender == "Female", ]
shapiro.test(female$Height)
qqnorm(female$Height)
mean(female$Height)
par(mfrow = c(1, 2))
male <- weight_height[weight_height$Gender == "Male", ]
shapiro.test(male$Height)
qqnorm(male$Height)
mean(male$Height)
var(male$Height)
female <- weight_height[weight_height$Gender == "Female", ]
shapiro.test(female$Height)
qqnorm(female$Height)
mean(female$Height)
var(female$Height)
t.test(male$Height, female$Height, var.equal = TRUE, alternative = 'greater')$p.value
t.test(male$Height, female$Height, var.equal = TRUE, alternative = 'greater')
t.test(male$Height, female$Height, paired = TRUE, alternative = 'less')$p.value
t.test(male$Height, female$Height, paired = TRUE, alternative = 'greater')$p.value
t.test(male$Height, female$Height, alternative = 'greater')$p.value
t.test(male$Height, female$Height, alternative = 'greater')
t.test(male$Height, female$Height, alternative = 'greater', conf.level = 0.05)$p.value
selected <- computers[computers$screen == 14, ]
View(selected)
ram_procent <- data.frame(cbind(liczebnosc = table(selected$ram),
procent = prop.table(selected$ram)))
table(selected$ram)
prop.table(selected$ram)
table(selected$ram)
liczebnosc <- table(selected$ram)
prop.table(liczebnosc)
prop.table(liczebnosc)*100
# ZAD 2 - tego trochę nie rozumiem
w_test <- function(x, istotnosc, delta_zero, alternative = c('two.sided', 'less', 'greater')) {
# statystyka testowa
ss <- (1 / length(x)) * (var(x) - mean(x))
statistic <- length(x) * ss / delta_zero * delta_zero
# parametr w obszarach krytycznych
d <- length(x) - 1
# poziom istotności
alternative <- match.arg(alternative)
p_value <- istotnosc
p_value <- switch(alternative,
'two.sided' = 2 * min(p_value, 1 - p_value),
'greater' = p_value,
'less' = 1 - p_value)
# rezultat
names(statistic) <- 'T'
names(d) <- 'num df'
result <- list(statistic = statistic,
parameter = d,
p.value = p_value,
alternative = alternative,
method = 'Test istotności dla wariancji w modelu normalnym',
data.name = deparse(substitute(x)))
class(result) <- 'htest'
return(result)
}