Unbiased RMSE ubrmse
I am writing simple function in R to calculate the unbiased RMSE (ubrmse) given a set of observed and expected values. The function I have so far is as follows:
library(hydroGOF)
ubRMSE < function(obs, exp) {
#Combine the observed and expected data into data frame
newDf < cbind.data.frame(obs, exp)
#Remove any rows containing NA values
newDf < newDf[complete.cases(newDf), ]
#Calculate r
r < as.data.frame(gof(sim = newDf[,2], obs = newDf[,1], digit = 4))
r < r[16,1]
#Calculate ubRMSE
ubRMSEStat < sqrt(var(newDf[,2]) + var(newDf[,1])  2 * r *
var(newDf[,2]) * var(newDf[,1]))
return(ubRMSEStat)
}
Can anyone tell me if both the function and the formula for the unbiased RMSE are correct? The formula was taken from the following publication https://pubag.nal.usda.gov/download/60040/PDF. I have not come across any packages which include a formula for the unbiased RMSE (hydroGOF, tdr) although many organizations seem to use the metric.
In addition, within the paper there appears to be estimation operators. Can this simply be considered as the mean estimated soil moisture value for a given day, or does it need to consider more?
Cheers,
Matt
*Edit: Punctuation, tags, formula and added citation
See also questions close to this topic

Loop in R, extracting the last line of the output
Hei guys,
I've been trying to extract the values from a loop for a while but it seems I just can't find the answer.
To make it simple, here is the code I'm using in R programme:
seatsInitial < function (df,x,y) { for (i in ModQuota) { filtered = subset(df, Poll> x) OnlyPoll < filtered$Poll Calculus < OnlyPoll/i Calculus2 < floor(Calculus) print(Calculus2) if(sum(Calculus2) == y) stop("WE GOT IT") } }
Then, to get the results:
seatsInitial(PartiesE, 5, 33)
The loop works properly and I am able to get the results I need. The loop stops when the condition is met. However, I would also need to convert the last line of the output (when the loop stops as a result of meeting the condition) into a vector.
Do you have any idea how this could be done?
If I run the loop, I get the following results (showing only the last 5 lines of the output here):
[1] 8 14 4 3 5 [1] 8 14 4 3 5 [1] 8 14 4 3 5 [1] 8 14 4 3 5 [1] 7 14 4 3 5 Error in seatsInitial(PartiesEPP, 5, 33) : WE GOT IT
I therefore need the last line (7,14,4,3,5) to be converted into a vector.
Thanks for your help!

Creating initialise method for reference class in R
I would like to create an initialize method for a reference class object in R that will provide default values for missing arguments. In the example above, the reference class object takes a data frame and some strings. If the comment string is missing timestamp is provides.
Class definition
#' Class SummaryData #' #' @description Odd class facilitating creation of data frame with #' summary information attached. #' #' @slot data data.frame. #' @slot summary_columns character. #' @slot info character. #' #' @return A SummaryData Class #' @import methods #' @exportClass SummaryData #' setClass( Class = "SummaryData", slots = list( data = "data.frame", summary_columns = "character", info = "character" ) ) #' Constructor method of SummaryData. #' #' @name SummaryData #' @rdname SummaryDataclass setMethod("initialize", "SummaryData", function(.Object, data = "data.frame", summary_columns = "character", info = "character", ...) { if (missing(data)) { data < data.frame() } if (missing(summary_columns)) { summary_columns < character() } if (missing(info)) { info < paste("Object generated on:", Sys.time()) } validObject(.Object) return(.Object) }) #' Wrapper function SummaryData. #' #' @name SummaryData #' @rdname SummaryDataclass #' @export SummaryData < function(...) { new("SummaryData", ...) }
Problem
>> SummaryData(data = airquality) An object of class "SummaryData" Slot "data": data frame with 0 columns and 0 rows Slot "summary_columns": character(0) Slot "info": character(0)
Desired results
info
slot should contain results ofpaste("Object generated on:", Sys.time())
data
slot should contain info onairquality
data, which is:dim(airquality) [1] 153 6

Value is definitely in the array, but it keeps returning false
In my
./includes/functions.php
I have the following functionfunction ck_rank($rank) { $strJsonFileContents = file_get_contents("./includes/globals.json"); $status = json_decode($strJsonFileContents, true); $ranks = array(); foreach ($status as $value) { array_push($ranks, $value); } if (in_array($rank, $ranks)) { echo "true"; } else { echo "false" ; } }
In my main.php I'm using this to check the return of that function, and if true, display a , if false, it won't show the
if (ck_rank($rank)) { <td>........</td> }
Problem is, no matter what, the function always returns false.
I'm really new at json, and I'm sure there's a better way, but any help would be greatly appreciated! ty  How to plan path from point 1 to point 2 so that it remains in the specified region?

Drawing a perpendicular line with a midpoint that meets in the middle
I have coordinates (x0,y0) and (x1,y1) that define a line of length L. I want to draw a line of length L that is perpendicular to this line such that the midpoint of the new line touches (x0,y0)  so that it forms a T. I need to obtain the coordinates (x3,y3) and (x4,y4) of this line.
I know that the slope of the original line is (y1y0) / (x1x0) and that the the slope of the new line will be 1 * the inverse of that.
This question is broadly similar (and probably quite simple) to this question:
Drawing line perpendicular to a given line
If I knew x3,y3 then I'd obviously be able to calculate x4,y4 easily, but I'm stumped at how to obtain the coordinates x3,y3.

calculate mod of fraction using pow in python
I would like to calculate the value of the Fraction 2/7**1000000 %13 in python with the built in method pow but pow only accepts numeric types.
My guess is that I need to calculate the inverse of 2/7 with extended euclid and then use that number in pow. Am I right?

Data perturbation  How to perform it?
I am doing some projects related to statistics simulation using R based on "Introduction to Scientific Programming and Simulation Using R" and in the Students projects session (chapter 24) i am doing the "The pipe spiders of Brunswick" problem, but i am stuck on one part of an evolutionary algorithm, where you need to perform some data perturbation according to the sentence bellow:
"With probability 0.5 each element of the vector is perturbed, independently of the others, by an amount normally distributed with mean 0 and standard deviation 0.1"
What does being "perturbed" really mean here? I dont really know which operation I should be doing with my vector to make this perturbation happen and im not finding any answers to this problem. Thanks in advance!

Python: Weighted coefficient of variation
How can I calculate the weighted coefficient of variation (CV) over a NumPy array in Python? It's okay to use any popular thirdparty Python package for this purpose.
I can calculate the CV using
scipy.stats.variation
, but it's not weighted.import numpy as np from scipy.stats import variation arr = np.arange(5, 5) weights = np.arange(9, 1, 1) # Same size as arr cv = abs(variation(arr)) # Isn't weighted

PCA results on imbalanced data with duplicates
I am using sklearn IPCA decomposition and surprised that if I delete duplicates from my dataset, the result differs from the "unclean" one.
What is the reason? As I think, the variance is the same.

Copper cable current Gauze calculation
I wanted to calculate theoretically current carrying capacity of cable. I have 24 Awg cable. Which is having 8 strands . overall dimension of the cable is 1.27mm and each strands dia 0.015 mm approximately. Now i need relation equation to calculate current carrying capacity of it. Sine i dont have datasheet can someone guide equation for calculating it.

SUM lots of half hourly data into a separate list
I currently have generation data over halfhourly time intervals. However there are about 70 entries for each half hour. What I want to do is make a column that aggregates all the generation for each time interval.
Currently my approach is this
=SUM(D2:D71)
and then in the next cellSUM(D72:D144)
etc. Surely there must be a more efficient way of doing this?Thanks

Most Common Value In Table Multiple Columns Excel
I have about 4,000 rows of text data, across 21 columns. The below formula will return the most common value in a single column:
{=INDEX(E6:E3876,MODE(IF(E6:E3876<>"",MATCH(E6:E3876,E6:E3876,0))))}
However, I need to check all cells in the E6:Y4000 range. Is there a way in Excel to return the most common, nonblank text value in a table that spans multiple columns?

Cannot install R packages on Azure Databricks: null TypeError
I am trying to install some R CRAN packages on Azure Databricks (for example, the lime package) using the default way (see screenshots below). This fails with slightly different error messages depending on whether I use Firefox or Chrome:
Error: TypeError: t is null (Firefox)
Error: Uncaught TypeError: Cannot read property 'toLowerCase' of null (Chrome)
Can anyone reproduce the error or know the reason for this? It might be a problem with the package, or with Databricks...
Possibly related question: this one

How to successfully download the old version of lsmeans package
I'd like to download version 2.263 of lsmeans package.
An error occurs when I try to download an old version of the lsmeans package. I've tried two options for downloading the old versions of lsmeans.
Option 1)
path< "http://cran.rproject.org/src/contrib/Archive/lsmeans/lsmeans_2.263.tar.gz" install.packages(path, repos=NULL, type="source")
Option 2)
library(devtools) install_version("lsmeans", version = "2.263", dependencies=FALSE, repos = "http://cran.rstudio.com/")
When I attempt either option, I am prompted to:
"These packages have more recent versions available. which would you like to update."
It then it lists a number of packages. I have attempted to choose both options "all" and "none"
The main error code I keep getting is this:
Error: (converted from warning) unable to access index for repository http://glmmadmb.rforge.rproject.org/repos/bin/windows/contrib/3.5:
cannot open URL 'http://glmmadmb.rforge.rproject.org/repos/bin/windows/contrib/3.5/PACKAGES'
why does it direct me to this glmmadmb.r address which no longer exists. Any suggestions?