Extract Regression Tables from R Studio to Lyx for research paper

112 Views Asked by At

Im working on a project that im searching what the effects of Risk-Taking behaviour on Entrepreneurship, i mean how culture affects the Entrepreneurial activities. I run regressions to see the impact of independent variables on the dependent variables which represent the presence of Entrepreneurial Intention.

I would like to exctract the regression tables and summary tables i have constructed to the LyX document processor in order to have a more scientific view.

Whats the process i must follow to do this ??

EDIT:

MY DATASET:

My dataset is quite big and even if i use the order: dput(head(GemData,10)) the result is very big to post it here !!! Any order way ?!

MY CODE:

## you need the 'haven' package for loading a .dta file 

library(haven)

GemData <- read_dta(("C:/Users/ILIAS/Documents/Bachelors Thesis/GEM Dataset.dta"))


#### Stepwise Regression for y1 = 'all_high_stat_entre' and y2 = 'all_fear_fail' ####


library(MASS)

index<-which(is.na(GemData$all_high_stat_entre)==F)

n = nrow(GemData)
r<-NULL
for(i in 2:n){
  r[i-1]=cor(GemData$all_high_stat_entre[index],GemData[index,i])
}

index.r<-which(is.na(r)==F)

## 'res' is that number of column which the response 'all_high_stat_entre' ## 
res = which(r==1)

#---------------------------------------------------------------------------------------

index_fail<-which(is.na(GemData$all_fear_fail)==F)

r_fail<-NULL
for(i in 2:n){
  r_fail[i-1]=cor(GemData$all_fear_fail[index_fail],GemData[index_fail,i])
}

index.r.fail<-which(is.na(r_fail)==F)

##  'res.fail' is that number of column which the response 'all_fear_fail' ##
res.fail = which(r_fail==1)


#### Stepwise regression of 'all_high_stat_entre' ####

index.r.mod = index.r[-res]
index.r.mod.1=which(abs(r)>0.3)

n.all_high = length(index.r.mod.1)

data.subset=GemData[index,index.r.mod.1]
data.subset[,(n.all_high + 1)]=GemData$all_high_stat_entre[index]
colnames(data.subset)=c(names(data.subset)[1:19],"all_high_stat_entre")

## fit a full model

full.model <- lm(all_high_stat_entre~.,data=data.subset)
min.model <- lm(all_high_stat_entre~1,data=data.subset)

## ols_step_all_possible(full.model)

library(olsrr)
ols_step_forward_p(full.model)

model.all.high = lm(all_high_stat_entre ~ all_entre_des+all_estab_bus_age2+all_est_bus_fem+all_fut_startbus+all_startbus_job+all_know_entre+all_est_bus_sect4,data=data.subset)
summary(model.all.high)
stargazer(model.all.high, title="Results",type='text')

fwd.model <- stepAIC(min.model, direction='forward', scope=(~all_entre_des+all_estab_bus_age2+all_est_bus_fem+all_fut_startbus+all_startbus_job+all_know_entre+all_est_bus_sect4),data=data.subset)

library(stargazer)
stargazer(fwd.model, title="Results",type='text')

#--------------------------------------------------------------------------------------------

#### Modeling for the response 'all_fear_fail' ####

index.r.mod.fail = index.r[-res.fail]
index.r.mod.fail.1=which(abs(r_fail)>0.3)

n.all_fail = length(index.r.mod.fail.1)

data.subset.fail=GemData[index_fail,index.r.mod.fail.1]
data.subset.fail[,(n.all_fail + 1)]=GemData$all_fear_fail[index_fail]
colnames(data.subset.fail)=c(names(data.subset.fail)[1:(n.all_fail)],"all_fear_fail")

## fit a full model

full.model.fail <- lm(all_fear_fail~.,data=data.subset.fail)
min.model.fail <- lm(all_fear_fail~1,data=data.subset.fail)

## ols_step_all_possible(full.model)

library(olsrr)
ols_step_forward_p(full.model.fail)

fwd.model.fail <- stepAIC(min.model.fail, direction='forward', scope=(~all_per_cap+all_know_entre+all_per_opp),data=data.subset.fail)

library(stargazer)
stargazer(fwd.model.fail, title="Results" , type='text')

Thanks in advance !

0

There are 0 best solutions below