econometricsr
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
econometricsr [2025/06/02 13:41] – [Exemples] glebelg | econometricsr [2025/06/04 11:44] (current) – glebelg | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====Start a script ==== | + | =====Start a script |
| | ||
library(stargazer) | library(stargazer) | ||
Line 13: | Line 13: | ||
data from Rdata | data from Rdata | ||
| | ||
- | ====Summary Stats==== | + | =====Summary Stats===== |
stargazer(dataset, | stargazer(dataset, | ||
Line 22: | Line 22: | ||
| | ||
| | ||
- | ====Regressions==== | + | =====Regressions===== |
linear | linear | ||
reg1 <- lm(depvar ~ var1 + var2 + var3, data=dataset) | reg1 <- lm(depvar ~ var1 + var2 + var3, data=dataset) | ||
+ | use rlm for robust regressions | ||
+ | | ||
| | ||
probit | probit | ||
Line 34: | Line 36: | ||
| | ||
| | ||
- | ====Exemples==== | + | =====Exemples===== |
install.packages(" | install.packages(" | ||
install.packages(" | install.packages(" | ||
Line 65: | Line 67: | ||
#generate variables in dataset | #generate variables in dataset | ||
db1$niveauscore <- db1$niveau * db1$score | db1$niveauscore <- db1$niveau * db1$score | ||
- | #option2 - si beaucoup d' | + | |
+ | #option2 - si beaucoup d' | ||
attach(db2) | attach(db2) | ||
db2$niveauscore <- niveau * score | db2$niveauscore <- niveau * score | ||
Line 87: | Line 90: | ||
#summary statistics table | #summary statistics table | ||
- | stargazer(as.data.frame(db1), | + | |
# tabulate | # tabulate | ||
- | table (" | + | |
- | db1 %>% tab(age, sexe) | + | db1 %>% tab(age, sexe) |
- | db1 %>% tab1(age, sexe) | + | db1 %>% tab1(age, sexe) |
- | db1 %>% ftab( sexe, age) | + | db1 %>% ftab( sexe, age) |
+ | |||
+ | =====Import/ | ||
+ | import excel | ||
+ | library(readxl) | ||
+ | db <- read_excel(" | ||
+ | View(db) | ||
+ | import stata | ||
+ | library(haven) | ||
+ | db <- read_dta(" | ||
+ | View(db) | ||
+ | |||
+ | export excel | ||
+ | install.packages(" | ||
+ | library(xlsx) | ||
+ | write.xlsx(db, | ||
+ | |||
+ | =====Data Manipulation===== | ||
+ | |||
+ | ====drop publicates==== | ||
+ | newdata <- distinct(dataset, | ||
econometricsr.1748871690.txt.gz · Last modified: by glebelg