regression

R: How to fit a time series model such as “Y(t) = αX + βY(t-1)”?

戏子无情 提交于 2021-02-08 08:18:15
问题 How do I fit this model in R, step by step? My scope is to make a forecast for t+1. Y(t) = αX(t) + βY(t-1) Y(t) <- years from 1900 to 2000. X <- a score measure from 0 to 100. Y(t-1) <- lagged value of order 1 for Y. Thanks in advance. 回答1: Your model is an AR(1) time series for y with covariate x . We can just use arima0 (no missing value) or arima (missing value allowed) from R base: fit <- arima0(y, order = c(1, 0, 0), xreg = x) Let's consider a small example: set.seed(0) x <- runif(100) #

change the default arguments of a function in R

醉酒当歌 提交于 2021-02-08 07:40:28
问题 I'm following up on this answer . I'm wondering if there is a way to set the default for argument rug to FALSE and argument multiline to TRUE in the plots generated by library(effects) as, for example, shown below in the code? library(effects) m <- lm(Fertility ~ Examination*Education, data = swiss) plot(allEffects(m), rug = FALSE, multiline = TRUE) # By default, change `rug = FALSE` # `multiline = TRUE ` 回答1: I think if you're just trying to add those two options to @MrFlick's answer you

Plotly: How to change the format of the values for the x axis?

ぐ巨炮叔叔 提交于 2021-02-08 07:29:34
问题 I need to create a graph from data with python. I took my inspiration from various website and I've made this script : import plotly.express as px import plotly.graph_objs as go import statsmodels.api as sm value = [1, 2, 3, 4, 5, 5, 5, 6, 6, 7, 8] date = [ 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020] fig = px.scatter(x=date, y=value ) fig.add_trace(go.Scatter(x=date, y=value, mode='lines',name='MB Used' )) trend = sm.OLS(value,sm.add_constant(date)).fit().fittedvalues

combine two plots into one plot in a mixed-model plot

点点圈 提交于 2021-02-08 06:41:06
问题 In my plot below, d_math and d_hyp are each {0,1} variables. Given this fact, in my plot below, I was wondering if we can combine the two plots into one, just like in the desired plot further below? ps. I'm open to any R packages. multivariate <- read.csv('https://raw.githubusercontent.com/hkil/m/master/bv.csv') library(nlme) library(effects) # for plot m2 <- lme(var ~ 0 + d_math + d_hyp + d_math:I(grade-2) + d_hyp:I(grade-2), random = ~ 0 + d_math + d_hyp + d_math:I(grade-2) + d_hyp:I(grade

combine two plots into one plot in a mixed-model plot

早过忘川 提交于 2021-02-08 06:40:55
问题 In my plot below, d_math and d_hyp are each {0,1} variables. Given this fact, in my plot below, I was wondering if we can combine the two plots into one, just like in the desired plot further below? ps. I'm open to any R packages. multivariate <- read.csv('https://raw.githubusercontent.com/hkil/m/master/bv.csv') library(nlme) library(effects) # for plot m2 <- lme(var ~ 0 + d_math + d_hyp + d_math:I(grade-2) + d_hyp:I(grade-2), random = ~ 0 + d_math + d_hyp + d_math:I(grade-2) + d_hyp:I(grade

How to use pytorch to construct multi-task DNN, e.g., for more than 100 tasks?

瘦欲@ 提交于 2021-02-08 06:25:15
问题 Below is the example code to use pytorch to construct DNN for two regression tasks. The forward function returns two outputs (x1, x2). How about the network for lots of regression/classification tasks? e.g., 100 or 1000 outputs. It definitely not a good idea to hardcode all the outputs (e.g., x1, x2, ..., x100). Is there an simple method to do that? Thank you. import torch from torch import nn import torch.nn.functional as F class mynet(nn.Module): def __init__(self): super(mynet, self)._

YOLOv4损失函数全面解析

拜拜、爱过 提交于 2021-02-08 05:40:04
点击上方“ 视学算法 ”,选择“ 星标 ”公众号 精选作品,第一时间送达 来源|周威@知乎,https://zhuanlan.zhihu.com/p/159209199 本文已获作者授权,不得二次转载。 1.前言 如果您对YOLO V4的结构比较感兴趣,建议您可以结合代码以及我的这篇文章进行 消化 。代码是基于Keras版本的,结构很清晰,链接如下: YOLO V4 Keras:https:github.com/Ma-Dan/keras-yolo4 YOLO V4相较于YOLO V3做了很多 小创新 ,堪称目标检测tricks万花筒。既然YOLO V4结构大家都懂了,根据网络的 输出 和 标签信息 进行损失函数的设定,实现网络参数的更新,一个完整的YOLO V4模型训练过程就可以被复现了。 YOLO V4原文中提到,在进行bounding box regression的时候,传统的目标检测模型(比如YOLO V3)等,都是直接根据 预测框 和 真实框 的 中心点坐标 以及 宽高信息 设定 MSE(均方误差)损失函数 的。为了方便大家理解,下面给出了YOLO V3的总损失函数。 YOLO V3的损失函数 可以看出,第一行的两个,就是用在bounding box regression的损失函数MSE。有关该损失函数的具体解析可以见我文章《YOLO V3 深度解析 (下)》(https:

How to get regression coefficients and model fits using correlation or covariance matrix instead of data frame using R?

你离开我真会死。 提交于 2021-02-07 18:18:25
问题 I want to be able to regression coefficients from multiple linear regression by supplying a correlation or covariance matrix instead of a data.frame. I realise you lose some information relevant to determining the intercept and so on, but it should even the correlation matrix should be sufficient for getting standardised coefficients and estimates of variance explained. So for example, if you had the following data # get some data library(MASS) data("Cars93") x <- Cars93[,c("EngineSize",

Random Forest interpretation in scikit-learn

假如想象 提交于 2021-02-07 13:47:37
问题 I am using scikit-learn's Random Forest Regressor to fit a random forest regressor on a dataset. Is it possible to interpret the output in a format where I can then implement the model fit without using scikit-learn or even Python? The solution would need to be implemented in a microcontroller or maybe even an FPGA. I am doing analysis and learning in Python but want to implement on a uC or FPGA. 回答1: You can check out graphviz, which uses 'dot language' for storing models (which is quite

Random Forest interpretation in scikit-learn

我与影子孤独终老i 提交于 2021-02-07 13:47:06
问题 I am using scikit-learn's Random Forest Regressor to fit a random forest regressor on a dataset. Is it possible to interpret the output in a format where I can then implement the model fit without using scikit-learn or even Python? The solution would need to be implemented in a microcontroller or maybe even an FPGA. I am doing analysis and learning in Python but want to implement on a uC or FPGA. 回答1: You can check out graphviz, which uses 'dot language' for storing models (which is quite