Julia presents various ways to carry out multiple regressions. One easy way is to use the lm() function of the GLM package. In this post I will present how to use the lm() and run OLS on the following model
Our dependent variable will be my weekly average weight, the explanatory variable
represents the sum of calories that I burned during the previous week, and variable
is a binary variable that takes a value of 1 in case I was cycling the week earlier and 0 otherwise. For a more detailed description of the data see here.
# load a couple of packages using DataFrames using XLSX # get data path = "https://economictheoryblog.files.wordpress.com/2016/08/data.xlsx" data = XLSX.readdata(download(path), "data", "A1:C357") data_df = convert(DataFrame,data[2:end,:]) names!(data_df, Symbol.(data[1,:])) data_df[:,:weight] = convert(Vector{Float64}, data_df[:,:weight]) data_df[:,:lag_calories] = convert(Vector{Float64}, data_df[:,:lag_calories]) data_df[:,:lag_cycling] = convert(Vector{Float64}, data_df[:,:lag_cycling]) # estimate the linear regression model glm(@formula(weight ~ lag_calories + lag_cycling), data, Normal(), IdentityLink())
if anyone knows how to do this..please contact me
hi jonathan, I just updated the post. It should work now. Let me know if you still encounter any problems. Best, ad