0

No bugs while compiling, but the issue is while trying to create a word document via Rmarkdown. Would be really grateful for any kind of advice. Do i need to install any additional packages?

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
##Question 1
install.packages("rmarkdown")
library(rmarkdown)
library(tidyverse)
library (readr)
Journals <- read_csv("Journals.csv")
model_lm1=lm(pages~society+field, data=Journals)
summary(model_lm1)
library(texreg)
texreg(model_lm1)
texreg::texreg(model_lm1)
htmlreg(model_lm1)

##Question 2
model_lm2=lm(pages~society*field, data=Journals)
summary(model_lm2)
BIC(model_lm1, model_lm2)
AIC(model_lm1, model_lm2)
summary(model_lm1)
summary(model_lm2)
##BIC shows that model 2 is better
##AIC shows that model 2 is also better

##Question 3
library(car)
vif(model_lm1)
model_lm1=lm(pages~society+field, data=Journals)
vif(model_lm1)
##value < 5 
sum(hatvalues(model_lm1)>2*mean(hatvalues(model_lm1)))
sum(abs(rstudent(model_lm1))>3)
sum(abs(rstudent(model_lm1))>3 & hatvalues(model_lm1) > 2*mean(hatvalues(model_lm1)))
qqPlot(model_lm1)
library(lmtest)
bptest(model_lm1)
library(texreg)
library(sandwich)
vcov=vcovHC(model_lm1)
sd=sqrt(diag(vcov))
t=coef(model_lm1)/sd
t
```
shafee
  • 15,566
  • 3
  • 19
  • 47
  • Welcome to SO. Can you make your post [reproducible](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) by providing your dataset or by using a built-in dataset (e.g., `mtcars`)? – jrcalabrese Nov 27 '22 at 18:47
  • However, if you are trying to print to a docx file, you should probably remove `include = FALSE`, since nothing will print when you knit to a docx. – jrcalabrese Nov 27 '22 at 18:50

0 Answers0