regression

Reading Data File into SAS

寵の児 提交于 2019-12-13 20:07:43
问题 This question was migrated from Cross Validated because it can be answered on Stack Overflow. Migrated 6 years ago . I have a data file that I am trying to import into SAS that looks something like the below: WCM2B W C M 2 B M.B 2 18.4 12.3 g WCM2B W C M 2 B M.B 2 19.2 12.3 g WCM2B W C M 2 B S.P 2 19.5 DQ ('') WCM2B W C M 2 B Z.G 2 17.7 10.7 g WCM2B W C M 2 B Z.G 2 18.4 10.7 g WCM2B W C M 2 B Z.G 2 17.6 10.8 g WCM2B W C M 2 B Z.G 2 20.1 12.1 g There are headings for each of these columns,

Efficiently calculating a segmented regression on a large dataset

我的梦境 提交于 2019-12-13 16:13:23
问题 I currently have a large data set, for which I need to calculate a segmented regression (or fit a piecewise linear function in some similar way). However, I have both a large data set, as well as a very large number of pieces. Currently I have the following approach: Let s i be the end of segment i Let (x i ,y i ) denote the i-th data point Assume the data point x k lies within segment j, then I can create a vector from x k as (s 1 ,s 2 -s 1 ,s 3 -s 2 ,...,x k -s j-1 ,0,0,...) To do a

Why does ggplot (.predict) not plot in R /rms package?

你。 提交于 2019-12-13 15:48:18
问题 Please find My Data of w and w1 at the bottom of this page. I have a Predictor ( w$test and w1$test ) which is the quantity of positive lymph nodes per total lymph node yield, i.e. ranging between 0 and 1. I have produced two models - each representing two different disease stages. I wish to plot them together but I all I get is this: The plot is produced with this code: library(ggplot2) library(rms) library(ggsci) d <- datadist(w) j <- options(datadist="d") d1 <- datadist(w1) j1 <- options

Polynomial regression with Apache Maths (Java)

和自甴很熟 提交于 2019-12-13 15:03:17
问题 Could anybody help me make a polynomial regression (order 2) with the Apache Math library. The following data should give this equation: 39.79 x^2 - 497.66 x + 997.45 (computed by Excel with r2 = 0.9998) // coding style from http://commons.apache.org/proper/commons-math/userguide/fitting.html double[] y = { 540.0, 160.0, -140.0, -360.0, -480.0, -560.0, -540.0, -440.0, -260.0, 0.0, 340.0}; final WeightedObservedPoints obs = new WeightedObservedPoints(); for (double figure:y){ obs.add(1.0,

Finding the slope for multiple points in selected columns

情到浓时终转凉″ 提交于 2019-12-13 14:40:16
问题 Given the following data frame: structure(list(`-5` = c(0, 1, 0, 0, 9, 22), `-4` = c(1, 3, 0, 0, 1, 17), `-3` = c(1, 3, 0, 0, 0, 12), `-2` = c(1, 3, 0, 0, 2, 10), `-1` = c(0, 0, 0, 4, 3, 9), `0` = c(0, 1, 0, 2, 2, 21 ), `1` = c(0, 1, 1, 7, 1, 21), `2` = c(1, 0, 1, 2, 1, 10), `3` = c(0, 9, 0, 6, 1, 12), `4` = c(0, 2, 0, 5, 0, 18), `5` = c(0, 0, 0, 3, 0, 23)), .Names = c("-5", "-4", "-3", "-2", "-1", "0", "1", "2", "3", "4", "5"), row.names = c(NA, 6L), class = "data.frame") # -5 -4 -3 -2 -1 0

Tensorflow on simple linear regression

折月煮酒 提交于 2019-12-13 13:26:57
问题 I am a beginner in machine learning and tensorflow. In the first step trying the tensorflow, I tried a simple multivariate linear regression. However, it seems the model stuck at a local minimum. Here is my code. import numpy as np import tensorflow as tf import matplotlib.pyplot as plt def weight_variable(shape): initial = tf.truncated_normal(shape, stddev=1) return tf.Variable(initial) # dataset xx = np.random.randint(0,1000,[1000,3])/1000. yy = xx[:,0] * 2 + xx[:,1] * 1.4 + xx[:,2] * 3 #

Rolling regression return multiple objects

筅森魡賤 提交于 2019-12-13 12:23:11
问题 I am trying to build a rolling regression function based on the example here, but in addition to returning the predicted values, I would like to return the some rolling model diagnostics (i.e. coefficients, t-values, and mabye R^2). I would like the results to be returned in discrete objects based on the type of results. The example provided in the link above sucessfully creates thr rolling predictions, but I need some assistance packaging and writing out the rolling model diagnostics: In the

Regression gives error on one of the input variables “contrasts can be applied only to factors with 2 or more levels” [duplicate]

风流意气都作罢 提交于 2019-12-13 10:37:28
问题 This question already has answers here : How to debug “contrasts can be applied only to factors with 2 or more levels” error? (2 answers) Closed last year . I am running a logit regression in R with a large number of input variables. newlogit <- glm(install. ~ SIZES + GROSSCONSUMPTION.... + NETTCONSUMPTION..... + NETTGENERATION....... + GROSSGENERATION.... + Variable. + Fixed + Cost.of.gross.cons + Cost.of.net.cons + Cons.savings + generation.gains + Total.savings + Cost.of.system + Payback +

How to extract coefficients outputs from a linear regression with loop

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-13 08:48:32
问题 I would like to know how I can loop a regression n times, and in each time with a different set of variables, extract a data.frame where each column is a regression and each row represent a variable. In my case I have a data.frame of: dt_deals <- data.frame(Premium=c(1,3,4,5),Liquidity=c(0.2,0.3,1.5,0.8),Leverage=c(1,3,0.5,0.7)) But I have another explanatory dummy variable called hubris , that is the product of a binomial distribution, with 0.25 of mean. Like that: n <- 10 hubris_dataset <-

statsmodels — weights in robust linear regression

半世苍凉 提交于 2019-12-13 07:26:39
问题 I was looking at the robust linear regression in statsmodels and I couldn't find a way to specify the "weights" of this regression. For example in least square regression assigning weights to each observation. Similar to what WLS does in statsmodels. Or is there a way to get around it? http://www.statsmodels.org/dev/rlm.html 回答1: RLM currently does not allow user specified weights. Weights are internally used to implement the reweighted least squares fitting method. If the weights have the