openair icon indicating copy to clipboard operation
openair copied to clipboard

Theil-Sen Trend Analysis

Open morshedahmed17 opened this issue 1 year ago • 5 comments

Question

I removed some months from the dataset for the Theil-Sen trend analysis, which I do not want to show in the plot. However, those points still appear in the plots, not exactly where they were before. Is it possible to remove them completely? Also, is it possible to remove the line joining the points?

morshedahmed17 avatar Feb 21 '24 06:02 morshedahmed17

Hi,

We'd be able to best help you if you can provide a reproducible example.

TheilSen() should only plot the data you use as an input, e.g.,:

library(openair)

alldata <- mydata

TheilSen(alldata, "nox")
#> Taking bootstrap samples. Please wait.


lessdata <- selectByDate(mydata, year = 2000:2002)

TheilSen(lessdata, "nox")
#> Taking bootstrap samples. Please wait.

Created on 2024-02-21 with reprex v2.0.2

More than happy to help if you can provide more info!

Jack

jack-davison avatar Feb 21 '24 14:02 jack-davison

Hello Jack,

Here is an example. I removed the entire 2012 ethane data. However, the monthly values are still showing in the plot.

image

morshedahmed17 avatar Feb 21 '24 15:02 morshedahmed17

When using the "deseason" option missing data is actually imputed using a Kalman filter and a Kalman smooth prior to doing the loess.

In other words, that is the probably the reason why the missing data is there. Quickest way to test is by setting "deseason" to FALSE.

mooibroekd avatar Feb 21 '24 22:02 mooibroekd

You are right. Just one quick question.

"If I set 'deaseason = FALSE', will the resulting trendline simply be a regression line?"

morshedahmed17 avatar Mar 08 '24 21:03 morshedahmed17

No, the output will still be a Theil-Sen analysis, but on data that has not been deseasonalized (meaning actual measurements).

mooibroekd avatar Apr 20 '24 19:04 mooibroekd