Skip to content
Snippets Groups Projects
Commit da2e6d2c authored by yousef's avatar yousef
Browse files

com.Stat_Ü4

parents
No related branches found
No related tags found
No related merge requests found
---
title: "übung4"
author: "Yousef Abdullah"
date: "2024-05-13"
output: html_document
----
```{r}
anzahl_Datensätze <- 1000 # 50
anzahl_Daten <- 500
Means_sim <- c()
for (i in 1:anzahl_Datensätze){
daten <- runif(n = anzahl_Daten, min = 0, max = 1)
mittelwert <- mean(daten)
Means_sim <- append(Means_sim, mittelwert)
}
Means_sim
```
```{r, echo = T, collapse = T}
# b
anzahl_Daten <- 500
Means_boot <- c()
daten_origin <- runif(n = anzahl_Daten, min = 0, max = 1)
anzahl_bootstrap <- 1000 # 50
for (i in 1:anzahl_bootstrap){
replikation_daten <- sample(daten_origin, size = anzahl_Daten, replace = TRUE)
mean_rep <- mean(replikation_daten)
Means_boot <- append(Means_boot, mean_rep)
}
Means_boot
```
```{r, }
hist(Means_sim)
hist(Means_boot)
boxplot(Means_sim)
boxplot(Means_boot)
shapiro.test(Means_sim)
shapiro.test(Means_boot)
```
```{r}
t.test(Means_sim, Means_boot, var.equal = TRUE, alternative = "two.sided")
```
---
title: "Test"
author: "Yousef Abdullah"
date: "2024-05-13"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
```{r}
anzahl_Datensätze <- 1000 # 50
anzahl_Daten <- 500
Means_sim <- c()
for (i in 1:anzahl_Datensätze){
daten <- runif(n = anzahl_Daten, min = 0, max = 1)
mittelwert <- mean(daten)
Means_sim <- append(Means_sim, mittelwert)
}
Means_sim
```
```{r, echo = T, collapse = T}
# b
anzahl_Daten <- 500
Means_boot <- c()
daten_origin <- runif(n = anzahl_Daten, min = 0, max = 1)
anzahl_bootstrap <- 1000 # 50
for (i in 1:anzahl_bootstrap){
replikation_daten <- sample(daten_origin, size = anzahl_Daten, replace = TRUE)
mean_rep <- mean(replikation_daten)
Means_boot <- append(Means_boot, mean_rep)
}
Means_boot
```
```{r, }
hist(Means_sim)
hist(Means_boot)
boxplot(Means_sim)
boxplot(Means_boot)
shapiro.test(Means_sim)
shapiro.test(Means_boot)
```
```{r}
t.test(Means_sim, Means_boot, var.equal = TRUE, alternative = "two.sided")
```
#A2
```{r}
daten_Trump <- Donald_1
anzahl_replikation_list <- c(50, 100, 1000, 10000)
coef_return_func <- function(daten, indices, k){
d <- daten[indices,]
model <- lm(Trump ~ ., data = d)
return(coef(model))
}
for (i in 1:length(anzahl_replikation)){
anzahl_rep <- anzahl_replikation_list[i]
parameter_df <- data.frame()
#daten <- sample(Donald_1, size = length(Donald_1), replace = TRUE , prob =)
#result <- boot(Donald_1, coef_return_func, R=anzahl_rep)
result<- boot(data = Donald_1, statistic = coef_return_func, R = 50)
result$t0
plot(result,index = 1)
}
```
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment