confidence-interval

Bootstrap Confidence Intervals in R

吃可爱长大的小学妹 提交于 2019-12-03 08:34:17
I am a new R user, and am having trouble using the boot package. All I want to do is use bootstrapping to produce confidence intervals around a mean for a vector of numbers, such as: x <- rnorm(100, 1, .5) Any tips? Doesn't the following suffice? library(boot) x <- rnorm(100, 1, .5) b <- boot(x, function(u,i) mean(u[i]), R = 999) boot.ci(b, type = c("norm", "basic", "perc")) 来源: https://stackoverflow.com/questions/9304582/bootstrap-confidence-intervals-in-r

Calculate confidence band of least-square fit

蓝咒 提交于 2019-12-03 04:28:16
I got a question that I fight around for days with now. How do I calculate the (95%) confidence band of a fit? Fitting curves to data is the every day job of every physicist -- so I think this should be implemented somewhere -- but I can't find an implementation for this neither do I know how to do this mathematically. The only thing I found is seaborn that does a nice job for linear least-square. import numpy as np from matplotlib import pyplot as plt import seaborn as sns import pandas as pd x = np.linspace(0,10) y = 3*np.random.randn(50) + x data = {'x':x, 'y':y} frame = pd.DataFrame(data,

scikit-learn - ROC curve with confidence intervals

天涯浪子 提交于 2019-12-03 02:02:13
问题 I am able to get a ROC curve using scikit-learn with fpr , tpr , thresholds = metrics.roc_curve(y_true,y_pred, pos_label=1) , where y_true is a list of values based on my gold standard (i.e., 0 for negative and 1 for positive cases) and y_pred is a corresponding list of scores (e.g., 0.053497243 , 0.008521122 , 0.022781548 , 0.101885263 , 0.012913795 , 0.0 , 0.042881547 [...]) I am trying to figure out how to add confidence intervals to that curve, but didn't find any easy way to do that with

Conditionally colour data points outside of confidence bands in R

久未见 提交于 2019-12-02 21:14:51
I need to colour datapoints that are outside of the the confidence bands on the plot below differently from those within the bands. Should I add a separate column to my dataset to record whether the data points are within the confidence bands? Can you provide an example please? Example dataset: ## Dataset from http://www.apsnet.org/education/advancedplantpath/topics/RModules/doc1/04_Linear_regression.html ## Disease severity as a function of temperature # Response variable, disease severity diseasesev<-c(1.9,3.1,3.3,4.8,5.3,6.1,6.4,7.6,9.8,12.4) # Predictor variable, (Centigrade) temperature<

scikit-learn - ROC curve with confidence intervals

时光怂恿深爱的人放手 提交于 2019-12-02 15:57:20
I am able to get a ROC curve using scikit-learn with fpr , tpr , thresholds = metrics.roc_curve(y_true,y_pred, pos_label=1) , where y_true is a list of values based on my gold standard (i.e., 0 for negative and 1 for positive cases) and y_pred is a corresponding list of scores (e.g., 0.053497243 , 0.008521122 , 0.022781548 , 0.101885263 , 0.012913795 , 0.0 , 0.042881547 [...]) I am trying to figure out how to add confidence intervals to that curve, but didn't find any easy way to do that with sklearn. ogrisel You can bootstrap the roc computations (sample with replacement new versions of y

How to add the results of applying a function to an existing data frame?

可紊 提交于 2019-12-02 08:06:59
问题 I am trying to calculate the confidence intervals of some rates. I am using tidyverse and epitools to calculate CI from Byar's method. I am almost certainly doing something wrong. library (tidyverse) library (epitools) # here's my made up data DISEASE = c("Marco Polio","Marco Polio","Marco Polio","Marco Polio","Marco Polio", "Mumps","Mumps","Mumps","Mumps","Mumps", "Chicky Pox","Chicky Pox","Chicky Pox","Chicky Pox","Chicky Pox") YEAR = c(2011, 2012, 2013, 2014, 2015, 2011, 2012, 2013, 2014,

How to add the results of applying a function to an existing data frame?

允我心安 提交于 2019-12-02 05:53:22
I am trying to calculate the confidence intervals of some rates. I am using tidyverse and epitools to calculate CI from Byar's method. I am almost certainly doing something wrong. library (tidyverse) library (epitools) # here's my made up data DISEASE = c("Marco Polio","Marco Polio","Marco Polio","Marco Polio","Marco Polio", "Mumps","Mumps","Mumps","Mumps","Mumps", "Chicky Pox","Chicky Pox","Chicky Pox","Chicky Pox","Chicky Pox") YEAR = c(2011, 2012, 2013, 2014, 2015, 2011, 2012, 2013, 2014, 2015, 2011, 2012, 2013, 2014, 2015) VALUE = c(82,89,79,51,51, 79,91,69,89,78, 71,69,95,61,87) AREA =c(

How do I plot the confidence interval when I provide the C.I. values

人走茶凉 提交于 2019-12-02 02:25:56
I am NOT plotting from the actual data, I only have a data.frame that list the x, y values as well as the upper and lower confident intervals. I want to plot line graph with confident interval. I want to plot something look like this: How do I do that? Here is the data.frame: grp x y se conf.low conf.high 0 0 66.27373472086 1.51067072892736 63.3124335788501 69.2350358628699 1 0 74.2148696059611 1.40010518400934 71.4703052207858 76.9594339911364 0 0.67 69.3077020704515 1.31170050247573 66.7364334799 71.8789706610029 1 0.67 76.3216788839049 1.20426555957627 73.9610102692502 78.6823474985597 0 1

How to calculate confidence intervals for a vector? [closed]

放肆的年华 提交于 2019-12-01 14:26:44
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed last year . I have a vector: vector <- c(12, 17, 24, 35, 23, 34, 56) How to calculate confidence intervals (90%, 99%, 95%) for this vector in R? This is example of result I want: enter image description here 回答1: Here is a function that will calculate your confidence interval according to the t-distribution:

How can I use pre bootstrapped data to obtain a BCa confidence interval?

流过昼夜 提交于 2019-12-01 12:47:20
I have bootstrapped two variables (one which is already in the "Impala.csv" file) using a function which resamples and reports the mean for a sample the size of nrow(data) for 5000 repetitions. The code is as follows: data<-read.csv("Impala.csv") allo<-data$distance data2<-read.csv("2010 - IM.csv") pro<-data2$pro n1<-nrow(data2) boot4000 <- c() for(i in 1:5000){ s <- sample(data2$xs,n1,replace=T,prob = data2$pro) boot4000[i] <- mean(s) }` and then combine the two outputs in a formula, giving me 5000 new variables. d<-(pi/2)*(boot4000*(1/allo)) Now I wish to find the BCa confidence intervals