regression

Determining regression coefficients for data - MATLAB

只谈情不闲聊 提交于 2019-12-11 19:33:01
问题 I am doing a project involving scientific computing. The following are three variables and their values I got after some experiments. There is also an equation with three unknowns, a , b and c : x=(a+0.98)/y+(b+0.7)/z+c How do I get values of a,b,c using the above? Is this possible in MATLAB? 回答1: This sounds like a regression problem. Assuming that the unexplained errors in measurements are Gaussian distributed, you can find the parameters via least squares. Basically, you'd have to rewrite

Pandas: Trouble implementing Panel OLS

大憨熊 提交于 2019-12-11 19:15:58
问题 I'm having a little bit of a difficult time understanding how to implement the Panel OLS in pandas. I have received help on this topic and I thought I was understanding the situation. Now that I am trying to implement I am having difficulty. Below is my data: url='https://raw.githubusercontent.com/108michael/ms_thesis/master/crsp.dime.mpl.df.1' df=pd.read_csv(url, usecols=(['date', 'cid', 'log_diff_rgdp', 'billsum_support', \ 'years_exp', 'leg_totalbills', 'log_diff_rgdp', 'unemployment',

Plotting Quantile regression with full range in ggplot using facet_wrap

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-11 18:45:07
问题 So I would like to plot entire full range quantile lines in full range when using facet_wrap . The code goes as follows: library(tidyverse) library(quantreg) mtcars %>% gather("variable", "value", -c(3, 10)) %>% ggplot(aes(value, disp)) + geom_point(aes(color = factor(gear))) + geom_quantile(quantiles = 0.5, aes(group = factor(gear), color = factor(gear))) + facet_wrap(~variable, scales = "free") #> [multiple warnings removed for clarity] Created on 2019-12-05 by the reprex package (v0.3.0)

Exponential regression function Python

别来无恙 提交于 2019-12-11 18:22:54
问题 I am trying to implement a exponential regression function. sp stands for sympy. I use numpy and sympy. Firstly, in func_exp I tried to use np.exp but it generated an error (attribute error), so I decided to use sympy instead. Well, this is the code import numpy as np from numpy.linalg import matrix_rank import scipy import scipy.integrate import random import matplotlib.pyplot as plt import matplotlib as mpl from mpl_toolkits.mplot3d import Axes3D from sympy import integrate import sympy as

calculating confidence interval of coefficient in poisson regression

不羁的心 提交于 2019-12-11 18:13:08
问题 The poisson regression looks as follows in My R-code: poissmod <- glm(aerobics$y ~ factor(aerobics$x1) + factor(aerobics$x2) + aerobics$x3 + aerobics$x4, family = poisson) poissmod Now I have to compute a confidence interval for the factor aerobics$x1 (in a model without aerobics$x1 since this is not significant). This might look very easy, but I am not familiar with R and I can 't find the answer anywhere... Anyone who can help me? Thanks a lot in advance! 回答1: See e.g. the confint function

Linear regression of time series over multiple columns

試著忘記壹切 提交于 2019-12-11 17:54:08
问题 I have the following problem. I want to compute the regression of an annual time series in matrix form. In total, I have 56 time series I extracted from gridpoints of an area I want to examine, so that I've got 56 values per year. I've plotted all values as points in a figure. Now I want to add a regression line to this figure, which contains all data. My goal is to compute the regression for the whole matrix. library(zoo) pdf(file="/home/user/name.pdf", pointsize=20, onefile = FALSE, width

R, automated loop of linear regressions using same IVs on different DVs to store coefficients

你离开我真会死。 提交于 2019-12-11 17:49:10
问题 Mtcars has 32 observations of 11 variables. Assume that "mpg", "drat", "qsec" are the dependent variables of interest. Assume that "cyl" and "hp" are the independent variables for model type 1 and "disp" is the independent variable for model type 2. I want to automate some regressions but can't do Step (2) below. What do I want to do? On my actual dataframe, I have many more dependent variables of interest than independent variables. I want to run "lm" or "glm" for each of the following: mpg

python OLS statsmodels T Stats of variables not entered into the model

ⅰ亾dé卋堺 提交于 2019-12-11 17:43:38
问题 Hi have created a OLS regression using Statsmodels I've written some code that loops through every variable in a dataframe and enters it into the model and then records the T Stat in a new dataframe and builds a list of potential variables. However I have 20,000 variables so it takes ages to run each time. Can anyone think of a better approach? This is my current approach TStatsOut=pd.DataFrame() for i in VarsOut: try: xstrout='+'.join([baseterms,i]) fout='ymod~'+xstrout modout = smf.ols(fout

Hypothesis test for intercepts in general mixed linear models with R

雨燕双飞 提交于 2019-12-11 17:08:05
问题 I have data of fixed effects: genotypes = C, E, K, M; age = 30, 45, 60, 75, 90 days; random effects: block = 1, 2, 3; and variable = weight_DM. The file is in: https://drive.google.com/open?id=1_H6YZbdesK7pk5H23mZtp5KhVRKz0Ozl I have the slopes linear and quadratic of ages for each genotype, but I do not have the intercepts and standard errors. The R code is: library(nlme) library(lme4) library(car) library(carData) library(emmeans) library(ggplot2) library(Matrix) library(multcompView) datos

Using LinEst () in .net

﹥>﹥吖頭↗ 提交于 2019-12-11 16:37:57
问题 I want to use Excel's buil-in function called LINEST() to do regression analysis in .net. I am able to use the function with squred matrix array, but when it is not square matrix say of order[12,3] then it gives error as: LinEst method of WorksheetFunction class failed Please help me out with this as it is very important for me to complete this code. This is my complete code: System.Data.DataTable dt = new System.Data.DataTable(); SqlCommand cmd =new SqlCommand("Select QtytoTransfer from DEmo