confidence-interval

Get Confidence Interval For One Point On Regression Line In R?

我的梦境 提交于 2019-11-28 02:08:38
问题 How do I get the CI for one point on the regression line? I'm quite sure I should use confint() for that, but if I try this confint(model,param=value) it just gives me the same number as if I just type in confint(model) if I try without a value, it does not give me any values at all. What am I doing wrong? 回答1: You want predict() instead of confint() . Also, as Joran noted, you'll need to be clear about whether you want the confidence interval or prediction interval for a given x. (A

Confidence interval for exponential curve fit

久未见 提交于 2019-11-27 22:19:59
I'm trying to obtain a confidence interval on an exponential fit to some x,y data (available here ). Here's the MWE I have to find the best exponential fit to the data: from pylab import * from scipy.optimize import curve_fit # Read data. x, y = np.loadtxt('exponential_data.dat', unpack=True) def func(x, a, b, c): '''Exponential 3-param function.''' return a * np.exp(b * x) + c # Find best fit. popt, pcov = curve_fit(func, x, y) print popt # Plot data and best fit curve. scatter(x, y) x = linspace(11, 23, 100) plot(x, func(x, *popt), c='r') show() which produces: How can I obtain the 95% (or

Control transparency of smoother and confidence interval

可紊 提交于 2019-11-27 18:13:09
问题 I'm refering to this SO question from 2 years ago, with ggplot : Adjust Transparency (alpha) of stat_smooth lines, not just transparency of Confidence Interval The first method suggested allows to set the alpha transparency of the confidence interval alone: ggplot(head(airquality, 60), aes(x=Day, y=Temp, color=factor(Month))) + geom_point() + stat_smooth(method = "lm", se=TRUE, alpha=1.0) The second method allows to set the alpha transparency for the line itself, but you loose the confidence

confidence interval with leastsq fit in scipy python

。_饼干妹妹 提交于 2019-11-27 14:14:03
问题 How to calculate confidence interval for the least square fit (scipy.optimize.leastsq) in python? 回答1: I would use bootstrapping method. See here: http://phe.rockefeller.edu/LogletLab/whitepaper/node17.html Simple example for noisy gaussian: x = arange(-10, 10, 0.01) # model function def f(p): mu, s = p return exp(-(x-mu)**2/(2*s**2)) # create error function for dataset def fff(d): def ff(p): return d-f(p) return ff # create noisy dataset from model def noisy_data(p): return f(p)+normal(0,0.1

Confidence intervals for predictions from logistic regression

二次信任 提交于 2019-11-27 09:00:15
问题 In R predict.lm computes predictions based on the results from linear regression and also offers to compute confidence intervals for these predictions. According to the manual, these intervals are based on the error variance of fitting, but not on the error intervals of the coefficient. On the other hand predict.glm which computes predictions based on logistic and Poisson regression (amongst a few others) doesn't have an option for confidence intervals. And I even have a hard time imagining

Confidence interval for exponential curve fit

孤者浪人 提交于 2019-11-26 23:03:41
问题 I'm trying to obtain a confidence interval on an exponential fit to some x,y data (available here). Here's the MWE I have to find the best exponential fit to the data: from pylab import * from scipy.optimize import curve_fit # Read data. x, y = np.loadtxt('exponential_data.dat', unpack=True) def func(x, a, b, c): '''Exponential 3-param function.''' return a * np.exp(b * x) + c # Find best fit. popt, pcov = curve_fit(func, x, y) print popt # Plot data and best fit curve. scatter(x, y) x =

Compute a confidence interval from sample data

狂风中的少年 提交于 2019-11-26 16:55:55
I have sample data which I would like to compute a confidence interval for, assuming a normal distribution. I have found and installed the numpy and scipy packages and have gotten numpy to return a mean and standard deviation (numpy.mean(data) with data being a list). Any advice on getting a sample confidence interval would be much appreciated. shasan import numpy as np import scipy.stats def mean_confidence_interval(data, confidence=0.95): a = 1.0 * np.array(data) n = len(a) m, se = np.mean(a), scipy.stats.sem(a) h = se * scipy.stats.t.ppf((1 + confidence) / 2., n-1) return m, m-h, m+h you

Extract prediction band from lme fit

两盒软妹~` 提交于 2019-11-26 12:37:38
问题 I have following model x <- rep(seq(0, 100, by=1), 10) y <- 15 + 2*rnorm(1010, 10, 4)*x + rnorm(1010, 20, 100) id <- NULL for(i in 1:10){ id <- c(id, rep(i,101)) } dtfr <- data.frame(x=x,y=y, id=id) library(nlme) with(dtfr, summary( lme(y~x, random=~1+x|id, na.action=na.omit))) model.mx <- with(dtfr, (lme(y~x, random=~1+x|id, na.action=na.omit))) pd <- predict( model.mx, newdata=data.frame(x=0:100), level=0) with(dtfr, plot(x, y)) lines(0:100, predict(model.mx, newdata=data.frame(x=0:100),