loess

loess regression on each group with dplyr::group_by()

梦想的初衷 提交于 2020-05-07 05:53:58
问题 Alright, I'm waving my white flag. I'm trying to compute a loess regression on my dataset. I want loess to compute a different set of points that plots as a smooth line for each group. The problem is that the loess calculation is escaping the dplyr::group_by function, so the loess regression is calculated on the whole dataset. Internet searching leads me to believe this is because dplyr::group_by wasn't meant to work this way. I just can't figure out how to make this work on a per-group basis

loess regression on each group with dplyr::group_by()

邮差的信 提交于 2020-05-07 05:50:48
问题 Alright, I'm waving my white flag. I'm trying to compute a loess regression on my dataset. I want loess to compute a different set of points that plots as a smooth line for each group. The problem is that the loess calculation is escaping the dplyr::group_by function, so the loess regression is calculated on the whole dataset. Internet searching leads me to believe this is because dplyr::group_by wasn't meant to work this way. I just can't figure out how to make this work on a per-group basis

r - loess prediction returns NA

浪子不回头ぞ 提交于 2020-04-09 17:55:25
问题 I am struggling with "out-of-sample" prediction using loess . I get NA values for new x that are outside the original sample. Can I get these predictions? x <- c(24,36,48,60,84,120,180) y <- c(3.94,4.03,4.29,4.30,4.63,4.86,5.02) lo <- loess(y~x) x.all <- seq(3,200,3) predict(object = lo,newdata = x.all) I need to model full yield curve, i.e. interest rates for different maturities. 回答1: From the manual page of predict.loess : When the fit was made using surface = "interpolate" (the default),

Calibration (inverse prediction) from LOESS object in R

限于喜欢 提交于 2020-01-22 03:32:18
问题 I have fit a LOESS local regression to some data and I want to be able to find the X value associated with a given Y value. plot(cars, main = "Stopping Distance versus Speed") car_loess <- loess(cars$dist~cars$speed,span=.5) lines(1:50, predict(car_loess,data.frame(speed=1:50))) I was hoping that I could use teh inverse.predict function from the chemCal package, but that does not work for LOESS objects. Does anyone have any idea how I might be able to do this calibrationa in a better way than

Can I export the result from a loess regression out of R?

萝らか妹 提交于 2020-01-06 04:05:10
问题 I have performed a loess regression on some data and plotted it. The problem is I'd like to export the black line and light red line (see figure) into excel. Is it possible? Clarification: I want to export the underlying data from the loess regression not the graph. Code used to calculate it: ggplot(data, aes(x=bigangle, y=meanz, colour=treatment)) + geom_point(data=df, aes(y = X2/median(df$X2), x=X8),color="red",alpha=.6) + geom_smooth(data=df, aes(y = X2/median(df$X2),x=X8),fill="red",

ImportError: cannot import name 'STL' from 'statsmodels.tsa.seasonal'

梦想与她 提交于 2020-01-02 10:19:55
问题 I have this issue now, I cannot import STL from statsmodels. I've tried to uninstall statsmodels as it was recommended somewhere with a similar issue but it is not possible, at least the way I do it: !pip uninstall statsmodels - NOT working. 回答1: It seems that the STL function from statsmodels is not included in the latest stable version of the library (0.10.2) but is in the dev version (0.11.0dev0). You can build and install this specific version with this command: pip install git+https:/

Emulating Google Sheets smoothed line chart with ggplot2

佐手、 提交于 2019-12-24 22:57:30
问题 I'm trying to emulate a Google Sheets smoothed line chart with ggplot2. It draws a smoothed line through all data points. plot in Google Sheets: The lines above and below is my hardcoded confidence intervals. data: library(tidyverse) data <- tibble( date = seq.Date(as.Date("2018-12-01"), as.Date("2018-12-20"), by = "days"), var = c(0.329,0.348,0.349,0.355,0.382,0.363,0.340,0.359,0.336,0.358,0.398,0.389,0.389,0.390,0.383,0.343,0.352,0.415,0.397,0.430), lower = c(0.311,0.330,0.330,0.336,0.364,0

Is there an implementation of loess in R with more than 3 parametric predictors or a trick to a similar effect?

北城余情 提交于 2019-12-24 04:48:06
问题 Calling all experts on local regression and/or R ! I have run into a limitation of the standard loess function in R and hope you have some advice. The current implementation supports only 1-4 predictors . Let me set out our application scenario to show why this can easily become a problem as soon as we want to employ globally fit parametric covariables . Essentially, we have a spatial distortion s(x,y) overlaid over a number of measurements z : z_i = s(x_i,y_i) + v_{g_i} These measurements z

How to plot regression or LOWESS lines over data in coplot

柔情痞子 提交于 2019-12-24 01:15:56
问题 It is often helpful to plot a line (e.g., a fitted regression line or a non-parametric LOWESS line) over data. Likewise, when variables are confounded, it is often helpful to plot x1, y data stratified by x2. However, I can't quite figure out how to combine both using ?coplot. This ought to be quite natural in lattice, but I can't seem to figure out how to do it there, either. The following provides some data to play with: library(MASS) set.seed(7422) X <- mvrnorm(100, mu=c(5,5), Sigma=rbind

loess line not plotting correctly

烈酒焚心 提交于 2019-12-19 08:11:20
问题 I'm having trouble fitting a loess smooth plus confidence limits to a scatterplot of residuals. My model is height ~ weight + chest circumference. To check linearity of chest circumference, I've fitted a model without chest circumference (i.e. height ~ weight), and plotted the residuals of this model against chest circumference. So far so good. I then tried to use loess() and predict() to plot a loess line, plus confidence limits. The result looks like this (in the picture I've only plotted